0

I am developing my application using Visual Studio 2015.

I have 6 projects in the solution of which 5 are libraries and one is a executable.

The executable project contains my test files and I am using Catch framework for testing. So I will be having 5 cppfiles in the executable project. How can I run each test one by one using CMake?

add_test function of CMake takes the executable name as command and runs all tests at once. I need to run each test separately.

Hayt
  • 5,210
  • 30
  • 37
Jackzz
  • 1,417
  • 4
  • 24
  • 53

1 Answers1

0

You can add multiple add_test calls with the right command line parameters.

In catch you can run a specific test by adding the name to the binary.

tester <testName>

So you can add those as arguments for the add_test call:

add_test(NAME mytest1 COMMAND tester test1 <...> )
add_test(NAME mytest2 COMMAND tester test2 <...> )
...

Then you can execute one specific test with

ctest -R mytest1 

This only runts mytest1. -R also takes a regex in case you want to run multiple tests.

Hayt
  • 5,210
  • 30
  • 37
  • Is this name of testcase or the particular cpp file? – Jackzz Oct 19 '16 at 10:50
  • @Jackzz yes. for more details see here: https://github.com/philsquared/Catch/blob/master/docs/command-line.md – Hayt Oct 19 '16 at 10:51
  • It is not only a name but a "testspec". you see more detail about this in the catch documentation. – Hayt Oct 19 '16 at 10:53