How can you select specific Google Mock test cases/unit tests to run?
c++, googletest, unit-testing
Solution
First of all, your unit tests should be lightning fast. Otherwise people are not going to execute them.
As explained in Selecting tests, you cam use `--gtest_filter=` option. In your specific case : `--gtest_filter=ClassAUnitTest.*`
Problem
I have multiple unit tests, each per class in a separate file. One of my standard unit tests looks like this: ``` #include "gmock/gmock.h" #include "gtest/gtest.h" class ClassAUnitTest : public ::testing::Test { protected: // Per-test-case set-up. // Called before the first test in this test case. // Can be omitted if not needed. static void SetUpTestCase() { //.. } // Per-test-case tear-down. // Called after the last test in this test case. // Can be omitted if not needed. static void TearDownTestCase() { //.. } // You can define per-test set-up and tear-down logic as usual. virtual void SetUp() { } virtual void TearDown() { } // Some expensive resource shared by all tests. //.. }; TEST_F(ClassAUnitTest, testCase1) { // Assign .. Act .. Assert. } ``` The way I know is to place DISABLED_ in front of the test case like this: ``` TEST_F(ClassAUnitTest, DISABLED_testCase1) { // Assign .. Act .. Assert. } ``` However it is very impractical to run all tests when working on one failing unit test. I use Visual Studio Ultimate 2013 with Gmock 1.7.0. Question: How can I easily select which Unit tests or specific tests to run, and which ones not?