c++ - Producing reference test files out of CPPunit test cases for a specification -
i'm writing reference implementation specification deals data transformation.
i have number of test cases check data getting forward , backward transformed properly, :
void test(){ int x[maxtest], y[maxtest], z[maxtest]; fillrandomly(x, testsize); mytransform trans = mytransform(testsize); trans.apply(x, testsize, y); trans.remove(y, testsize, z); for(int = 0; < testsize; i++) cppunit_assert(abs(x[i] - z[i]) < 2); } data types vary wildly between test cases , transforms.
what produce files contain input/output , maybe intermediary stage further implementations can verify results.
there few obvious ways can make work (e.g. name output file , slap in it) of them imply going each test case , whole bunch of copy pasting.
coming java, introspection comes mind wrapper solve of issues (automatic naming of test output files ...), not , i've been recommended stay away in c++ (opinions welcome).
generic apply / remove methods seem candidate won't easy there no abstract transform type , little conformity between transforms (might still option there aren't many types of transforms).
so i'm wondering if of had similar , how solved it. don't mind modifying test cases if means later on can have clean.
any input appreciated.
what you've described not unit test, , cppunit alone not best choice.
it looks you're trying 3 independent things, have combined them them @ 1 time. want run unit tests, want generate test data, , want verify program works generated data, , you're attempting within single unit test framework. because it's doing much, you're finding hard reuse.
consider simplifying 3 total testing apps: cppunit test suite executes unit tests (and these tests should have nothing files of test data); test data generator; , transformation tester. every time build should run automated unit tests. when run data generator, should automate execution of tester on data outputted ensure you've generated data. can deliver known tested data , tester app clients.
Comments
Post a Comment