Is there any SW to generate unit tests in C and embedded applications? The reason I am asking is that my boss told me he heard from someone that "You need a tool to analyze the code and create 80% of all relevant testcases automatically, the remaining 20% you use all your time and focus on", else it would take "too much time".
I am very skeptic about this statement and can't see clearly what kind of tests that could be auto generated and if they would be any good at all.
I can, however, see that it would be possible to generate interface unit tests automatically for the API:s.
So can someone enlighten me on this issue?
I recommend API Sanity Checker tool:
An automatic generator of basic unit tests for a shared C/C++ library. It is able to generate reasonable (in most, but unfortunately not all, cases) input data for parameters and compose simple ("sanity" or "shallow"-quality) test cases for every function in the API through the analysis of declarations in header files.
The quality of generated tests allows to check absence of critical errors in simple use cases. The tool is able to build and execute generated tests and detect crashes (segfaults), aborts, all kinds of emitted signals, non-zero program return code and program hanging.
Unique features:
See examples for FreeType2.
I'm author of this project and you can ask me any questions on it.
Your boss has got the wrong end of the stick.
I know of no tools that will generate unit tests for you.
What he may be mistaking is code coverage and unit testing. While related they are in fact separate issues.
Code coverage will instrument your code and once finished running give you the low down on how much of your source was used in the run. This is useful when unit testing as it will effectively show you where you have tested and where you need to focus your work.
It is fairly easy to get the first two thirds of code covered but diminishing returns means to get near a magic 100% takes a lot of time and effort.
Googling "unit test generator" turns up a lot of things, but I do not know if they are any good, or if they'll suit your case.
It is not unit testing, but you can do some code checking with lint or related tools. See: http://www.lysator.liu.se/c/ten-commandments.html I think a current open source tool is splint http://www.splint.org/
Jon Bentley's books have some good discussion of the role of "scaffolding" code, including test scaffolds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With