Hey guys, im facing a problem with my cppunit testing. I did a simple C++ program which basically extract data from a file based on its unique id. I would like to use cppunit to check if the data is correct.
I been reading up on it and i have yet to see any examples of c++ cppunit testing . Can anybody help me in this.
Sorry, let me explain furthur. What i am having a problem is , i do not get how the cppunit can read the output from a project and then check that value....
Can anibody show me how the coding would look like in order to extract the output and then compare it to a certain value? i read both links before but i do not really get it.
hmm, nope lol, i dont know her. Basically, we reading information from a website and based on certain id , we will extract the information.
We have to use cppunit for testing, and the information regarding it on c++ is really very little.
the type of data we trying to extract are some values displayed in the text file, like 23.3344 or -233.
What i know is that in cppunit, it will compare the values to check if the test pass or fail. but how do i go about getting it to check the output of the program to the values i input in the cpp unit?
I've used a number of unit testing frameworks including cppunit and none work as well as Boost Test. It has facilities for checking stdout.
However, your design is not very testable. In general, it is best to pass in an ostream reference and write to that. In your program you would pass std::cout. For testing you might pass in a std::ostringstring and then test the results of its buffer.
Test-driven development, where you actually write you unit tests first, has the major benefit that your code naturally comes out testable.