iSYSTEM testIDEA professional version now offers a feature to write the test specification at the same time you are writing your application's code.
For those that do not know about testIDEA: testIDEA provides realtime Unit Testing by execution of test cases and test vectors on the real customer hardware without code instrumentation. Primarily testIDEA is a free and open programming interface (API) that is completely integrated in winIDEA. With that API set one can write test applications/cases but also automatically execute them on customer’s hardware connected by iSYSTEM tools. testIDEA also includes an interactive editor for generating test cases and test reports.
Additional to above you can now also write down a test specification in your source code and testIDEA will extract that test spec and execute it. Assume you are a developer or code reviewer: Already when you write (or read) the source code, you think about function parameters and their limits. So, wouldn't it be a good idea to write down a test specification already at that point?
In general unit tests are tightly related to specific sections of the source code. Usually each test belongs to one function. Therefore it makes sense to keep test specifications in the same file - in the source code. To add a test specification, mark it with the special C/C++ comment string /*# which is a standard C/C++ multi-line comment followed by #. Below you see two functions plus test specificatons (different parameters transfers are used to show possible syntax):
/*#
- func: [Func1, [], rv]
params: [3]
expect:
- rv == 13
- func: [Func2, [3, ´a´, -1], rv]
expect:
- rv == 0x41
*/
int Func1(int i)
{
int x=0;
for (;x<10;++x)
++i;
return i;
}
long Func2(int i,char c, long l)
{
int x=0;
long y=0;
for (;x<10;++x)
y+=x+i+c+l;
return y;
}
When you open in testIDEA the source code file including the test specifications, testIDEA will parse the code and find above test specs. When you change the test specification in testIDEA, the change will be written back to the source code file into the comment lines.
More information (including the syntax) can be found in testIDEA's online help file.