How to get Google Test to execute multiple test files in QtCreator?

Viewed 572

I used Google Test in Qt Creator and wrote two test files, one is tst_a.h(generated by default).
The other file is tst_b.h, which I created automatically, but only tst_a.h is executed during unit test.
How can I get Google Test to execute tst_b.h?
Please find contents of files mentioned above.

This is tst_a.h

#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>
#include "Decimal.hpp"
using namespace testing;
TEST(contractTestCase, contractTestSet)
{
    EXPECT_EQ(1, 1);
    ASSERT_THAT(0, Eq(0));
}

this is tst_b.h

#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>

using namespace testing;
TEST(testNormal, contractNormalTestSet)
{
    EXPECT_EQ(1, 1);
}
1 Answers

When you write your tests in header files these header files need to be included in a cpp for them to be seen by the compiler. The default test setup starts out with a main.cpp in which you can add the include for your new .h file.

Related