my intention is to execute code coverage report with gcovr to my tests that are written with gtest framework with CMake.
ClassUnderTest.h:
class ClassUnderTest
{
public:
uint8_t Start(int in_a, int in_b);
static uint8_t MethodToTest(int a, const uint8_t *b, uint32_t c);
}
I have 2 test cases. One uses "TEST"s the other uses "TEST_F"s (a.k.a Test fixtures).
Test without Fixture:
TestCase1.cpp:
TEST (Test_Start, MethodToTest_test)
{
ClassUnderTest TestObj;
EXPECT_EQ(TestObj.Start(1,2),0xFF));
}
Test with Fixture:
TestCase2.cpp:
class ClassUnderTest_Test : public ::testing::Test, public ClassUnderTest
{
public:
virtual void SetUp();
virtual void TearDown();
bool TestCase2();
};
bool ClassUnderTest_Test :: TestCase2()
{
uint8_t retval;
retval = ClassUnderTest::MethodToTest(1,2,3);
return retval;
}
TEST_F( ClassUnderTest_Test , MethodToTest_test )
{
ASSERT_EQ( TestCase2(), true );
}
In both cases ClassUnderTest.cpp.gcno is generated and inside the data seems valid, but then when I call gcovr in a following way:
python C:\Python27\Scripts\gcovr --html --html-details -o output-file-name.html
Only the coverage of TestCase1 found in the html report, TestCase2 coverage is not visible at ClassUnderTest.cpp.
What can be the problem?
Thank you in advance.