0

I have learnt how to use ctest with add_test("base64 conversion" utils.exe) e.g. I would like to know if there is a common pattern to perform several tests with the same executable. I have a util component that does many things, for example base64 encoding, base64 decoding, base85 encoding, base85 decoding, own timer testing. So classes are Base64, Base85, Timer, ...

add_test(base64_encoding utils base64_encoding)
add_test(base64_decoding utils base64_decoding)
add_test(base85_encoding utils base85_encoding)
add_test(base85_decoding utils base85_decoding)
add_test(timer_create utils timer_create)
add_test(timer_set_timeout utils timer_set_timeout)

This is a way to pass-in the testname to be executed as args, and in utils.exe I can get the argv[1] and perform a string compare to know which test to run. It looks to be a bit ugly, and creating one executable target per test seems also ugly because I have too many classes in my utils, and for each family something like 100 unit tests. Is there a magic way to organize all of this please? many thanks

windev92
  • 1
  • 1
  • CTest just provides functionality to run a executable and check the exit code. What this executable does is entirely up to you. I'd recommend using some unit testing framework combined with CTest. At work we're using 1 cmake test case per component of our product, for unit testing, all of those tests use the boost unit test framework to run several independent unit tests and store the results in a JUnit xml file. – fabian Mar 30 '21 at 18:09
  • Google test might be worth a shot. – usr1234567 Mar 30 '21 at 21:56

1 Answers1

0

create_test_sourcelist is the guy to use. one executable for several tests

windev92
  • 1
  • 1