Testing is a fundamental part of any software project that involves adequate planning and foresight. If you are a business and are creating software for a client, your finished product must be thoroughly tested in order to ensure that the customer will be satisfied. There are a number of strategies for testing such as system testing, integration testing and unit testing. Unit testing is perhaps the most fundamental because it looks at the smallest testable part of code and only moves on to the next stage if this code passes all tests thrown at it. Testing frameworks such as CxxTest are also important in order to streamline unit testing and provide automation and feedback.
Throughout the course of this semester, I have found testing to be a necessary (and sometimes painful) part of all the programming I have done for the class project. For Iteration 1, I vividly remember trying to create my entire main.cpp file before doing any tests. I am not lying when I say that the first time I tried to compile my code, I got about 200 errors. Looking back, I realize that if I would've maybe tried to get only one regular expression to output the correct token/lexeme combination to start with rather than all thirty six expressions at once, I probably could have saved a lot of time and effort. This is the idea behind unit testing. Unit testing focuses on getting the smallest testable parts of a program functioning error-free before moving on to later stages of development. You can easily see where an error might be coming from since you are looking at relatively small sections of code. As the iterations and labs have continued, my partner and I have found it very helpful to take a little extra time to make sure that all of the small parts of our code are working before we move on. If they are not all working, it is generally easy to spot our mistakes.
CxxTest has been a very useful testing framework that we have used for the labs and for the project as well. It has provided an easy way to make sure that our code is running properly via simple .h files that contain our test methods. CxxTest provides the necessary C++ files to make the tests function and the user specifies what tests need to be run. The user simply builds the tests and CxxTest goes from there. This automation is extremely useful and works well for unit testing. One of the nice features about CxxTest in my opinion is the feedback that it provides. When you run tests, it can output the number of tests that failed and show you the number of tests that were successful over the number of total tests. It will also let you know if all tests passed.
When performing tests on your code, it is fundamental that you do not just do tests on your entire project after completion. You need to be actively testing while you are building your code and testing every relevant possibility in each stage. Unit testing helps do this by making sure that every piece of code that you are making is fully functional. CxxTest, with its ease of use and ability to automate unit tests, streamlines this testing process. Overall, CxxTest and unit testing provide a huge advantage to the programmer or business that decides to use them by ensuring accuracy and helping create error-free code.