views:

155

answers:

4

Hello all,

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?

+4  A: 

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.

graham.reeds
I just looked at Microsoft Pex. It seems to generate interface tests for C# code. Perhaps something similar for C could be a big advantage?
Henrik
Still looks like Pex needs to instrument your code to generate the test results.
graham.reeds
+1  A: 

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.

Sandy
A: 

We use CANtata here where I work for generating unit tests / code coverage. Its decent, though I imagine it is a bit pricey.

espais
A: 

We use IBM RTRT

http://www-01.ibm.com/software/awdtools/test/realtime/index.html

Although in our use case we don't use it to generate the tests, but I saw some possibilities to generate at least skeleton.

XAder