简体   繁体   中英

Check Unit Test - Separating Test Suites Into Different Files

I have a small library that uses helper .c files to do various tasks for the API. I would like to separate the test suites that test each component into different files. Is there a way to do this in Check?

For instance, if I had a Money library (as in the example) I might want to write a currency conversion library test suite it in its own file (check_convert_currency.c) I might want to create, track, etc in a different test suite (check_manipulate_money.c). I would like to check all test suites with check_money.c.

I think the best way to do this would be to create the .c files and headers for the above, include them in the check_money.c and add all test suites to the suite runner in main.

I would like to do this to keep the test files readable. If there is a better method or approach in attaining this goal, I am open to learning about it.

One approach used is to have one make file for each test file. This way you will have multiple test executables for multiple aspects of the same unit under test. So you would compile with different test executable - check_convert_currency and check_manipulate_money.

If you want to have the same executable for all tests then you can have header only implementations of the tests in check_manipulate_money.h and check_convert_currency.h .

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM