0

I want to automatically generate a lot of test functions. I am using cpptest tool where the standard way to add test is

TEST_ADD(MyTest::test1)
TEST_ADD(MyTest::test2)
...
TEST_ADD(MyTest::test100)

where I need to manually write test functions from void test1(){...} to void test100(){...}. I want to change this to be like this

for(i=0;i<100;i++)
    TEST_ADD(MyTest::test(i))

but TEST_ADD does not support functions with parameters. I had idea to automatically generate cpp file with all this 100 functions and then compile it in runtime, but this solution sounds to complicated. Is there some good way to organize such testing?

Back to the real problem, I have program with command line arguments like this

algorithmName parm1 parm2 ... parmN

I want to write unit tests to test all (or almost all) combinations of command line arguments, and each combination should be separate test in order to easily identify which combination failed. Is there some standard way to do this?

2
  • 2
    Related to how-to-parametrize-a-test-using-cppunit Commented Aug 21, 2014 at 11:32
  • You can write a script which writes your source file. Commented Aug 21, 2014 at 12:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.