clstaudt
clstaudt

Reputation: 22438

Googletest does not run test fixture

I am trying to use googletest for unit testing in C++. I have defined a text fixture in ClusteringTest.h:

#include <gtest/gtest.h>

namespace EnsembleClustering {

class ClusteringTest: public ::testing::Test {

    ClusteringTest() {};

    virtual ~ClusteringTest() {};

    virtual void SetUp() {

    };

    virtual void TearDown() {

    };

};

TEST_F(ClusteringTest, doesGTestWork) {
    EXPECT_EQ(42, 42);
}


} /* namespace EnsembleClustering */

In my main function, I call:

 ::testing::InitGoogleTest(&argc, argv);
 return RUN_ALL_TESTS();

The result is:

running EnsembleClustering
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (1 ms total)
[  PASSED  ] 0 tests.

Why is my test not run?

Upvotes: 3

Views: 5016

Answers (1)

Open AI - Opting Out
Open AI - Opting Out

Reputation: 24133

You need to include your header, ClusteringTest.h, into a .cpp file somewhere to make it concrete, and to create a compilation unit.

Upvotes: 6

Related Questions