Question

I need to provide unit tests for an application written in c++, this is a very big application and content many sources (.h, .cpp) , actually I don't know where to start? How to process? ... So any help is more than welcome.

Thanks

Was it helpful?

Solution 2

Grab a good test framework.

I have used google test a lot with my last company, and it was pretty good, though there are likely better around. Reading: http://code.google.com/p/googletest/ Comparison of c++ unit test frameworks

OTHER TIPS

Did you upset someone? Given there are no unit tests, the chances of the code being written to be testable range from slim to absolutely none.

Without seeing the code and spending several weeks if not months with it no one can give you more than a general strategy.

There will be some functions you can write unit tests for. Those will be ones where the arguments are easy to generate, they do very few things, one thing would be nice, and they don't have side effects. Attack these first, get them out of the way.

There will be others which nearly fit the above. Now you'll be tempted to re-engineer them a bit so they do, don't do it until you have some sort of test. Write tests for the bits you can. Write integration tests where you can't.

So the basic idea is to get as many tests as you can before you start changing the code, so you can test it and then, to make the smallest change possible to make the code better and write the tests first!

There are a fair few patterns or strategies you can use (get a good book on re-factoring legacy code), start with the simple ones.

Prepare for dismay, hard work and rework, but the best piece of advice I can give is don't try to take short cuts, after all that's what the chuffer who left you with this did isn't it?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top