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?

3
  • 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 7, 2019 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 7, 2019 at 20:23
  • 1

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.