How to integrate C/C++ test case with Teamcity

Hi there,

I tried to integrate our C/C++ test case with teamcity Test report by using Service Messages.
But I found the test report didn't display the right nunber of failed cases, my implementation as following:

C test cases
--------------------------------------------------------
#include <stdio.h>

/*Function return success*/
void test_1()
{
        printf("\t\t##teamcity[testStarted name='TEST_1']\n");
        printf("case: TEST_1\n");
        printf("\t\t##teamcity[testFinished name='TEST_1']\n");
}

/*Function return failed*/
void test_2()
{
        printf("\t\t##teamcity[testStarted name='TEST_2']\n");
        printf("case: TEST_2\n");
        printf("\t\t##teamcity[testFailed name='TEST_2']\n");
}

/*Function return success*/
void test_3()
{
        printf("\t\t##teamcity[testStarted name='TEST_3']\n");
        printf("case: TEST_3\n");
        printf("\t\t##teamcity[testFinished name='TEST_3']\n");
}


/*Function return failed*/
void test_4()
{
        printf("\t\t##teamcity[testStarted name='TEST_4']\n");
        printf("case: TEST_4\n");
        printf("\t\t##teamcity[testFailed name='TEST_4']\n");
}

int main()
{
        test_1();
        test_2();
        test_3();
        test_4();
        return 0;
}
________________________________________

when I trigger the build, the test report show as(Seems test_2 is not accounted):
-----------------------------------------------------------------------
Total test count: 3; total duration: < 1s

Tests to show: 50 100 500 All
Find:    Updating tests table ...
Status Test Duration Order#
Failure TEST_4           View test details 38ms View trend 3
OK TEST_1           View test details 1ms View trend 1
OK TEST_3           View test details < 1ms View trend 2


------------------------------------------------------------------------------

when I re-order the test case as
-------------------------------------------------
int main()
{
         test_1();
         test_3();
         test_4();
         test_2();
       return 0;
}
the test report show as:
----------------------------------------------------------
Total test count: 3; total duration: < 1s

Tests to show: 50 100 500 All
Find:    Updating tests table ...
Status Test Duration Order#
Failure TEST_2           View test details 43ms View trend 3
OK TEST_3           View test details 1ms View trend 2
OK TEST_1           View test details < 1ms View trend 1



and the build log show as:

[01:57:09]: case: TEST_1
[01:57:09]:
[01:57:09]:
[01:57:09]: case: TEST_3
[01:57:09]:
[01:57:09]:
[01:57:09]: case: TEST_4
[01:57:09]:
[01:57:09]:
[01:57:09]:
[01:57:09]:
[01:57:09]: TEST_2
[01:57:09]: [TEST_2] case: TEST_2
[01:57:09]: [TEST_2]
[01:57:09]: [TEST_2]
[01:57:09]: [TEST_2]
[01:57:09]: [TEST_2] Process exited with code 0

------------------------------------------------------------------

There should be 4 cases and two failure. but the report seems not as expected, can you help me on this issue?
Thanks in advance.

Gary Xu

2 comments
Comment actions Permalink

If test failed you still need to send testFinished message. Actually there is plugin for CPP unit tests: http://www.jetbrains.net/confluence/display/TW/Cpp+Unit+Test+Reporting

0
Comment actions Permalink

It works fine.
Thanks for your timely help.

Regards
Gary Xu

0

Please sign in to leave a comment.