0

I have a C++ project built using CMake. Following is what I do to build it.

mkdir build && cd build && cmake .. && make

make test runs all the unit tests which are built gtest.

Given that I have a test like below, how can I run only one specific test?

// This is MyClassAPI_test.cpp
TEST(MyClassAPI_test, MyClassAPITest) {
    EXPECT_TRUE(true);
}

I tried running

make check TESTS='MyClassAPI_test'

but it does not work?

AdeleGoldberg
  • 1,289
  • 3
  • 12
  • 28
  • I'm having trouble understanding what autotools has to do with your issue. Also, are you missing a `cd build` in your build commands? Or are you actually running the `cmake` command from outside the `build` directory? – Kevin Oct 07 '19 at 16:38
  • The command you tried is the correct way to do it if you are using autotools to generate the makefile, but it seems you're using cmake instead. With a makefile generated by cmake it will be completely different and you should check out the cmake manual. – ptomato Oct 07 '19 at 20:23
  • 1
    [how-to-run-specific-test-cases-in-googletest](https://stackoverflow.com/questions/12076072/how-to-run-specific-test-cases-in-googletest) ? – KamilCuk Oct 07 '19 at 20:28

1 Answers1

0

If you are using cmake, make test uses ctest executable behind.

To launch only the wanted test, from build directory use this command: ctest -R MyClassAPI_test

For further info, see : testing-using-ctest

souch
  • 181
  • 2
  • 3