Output of QTestLib unit-tests: "time"-attribute in testcase-element when using -xunitxml

  • Hi everybody,

    I want to use QTestLib unit-tests in a jenkins continuous integration server:


    which supports xunit-formatted test results.

    This output format is in general supported in the QtestLib framework; running the resulting unit-test with the -xunitxml commandline flag. (Please refer to the QtestLib manual for details)

    Now I'm stuck with two things, and I wonder if someone could kindly help me:

    Does anybody know whether there exists an official schema for the XUNIT-format?
    I googled some but none of them looks very official to me:

    All of the schemas I found have a time-attribute in the testcase-element. Jenkins supports that attribute and produces nice trend plots of the time required by individual tests. However I cannot get my QTestLib unit-test applications to fill this attribute.
    Here is the output of my sample:

    $>./sample1 -xunitxml
    <?xml version="1.0" encoding="UTF-8" ?>
    <testsuite errors="0" failures="0" tests="5" name="ccs::test::ModulSample1">
    <property value="4.7.3" name="QTestVersion"/>
    <property value="4.7.3" name="QtVersion"/>
    <testcase result="pass" name="initTestCase"/>
    <testcase result="pass" name="toUpper"/>
    <testcase result="pass" name="toLower"/>
    <testcase result="pass" name="usleepBenchmark">
    <testcase result="pass" name="cleanupTestCase"/>

    The toUpper and toLower testcases are slight modifications of the Chapter1: “Writing a Unit Test” example. Both use the QCOMPARE macro. The usleepBenchmark testcase uses the QBENCHMARK macro on a usleep()-call.
    Both don't give me the result I would need - which is something like:

    <testcase result="pass" name="usleepBenchmark time="2.3"> </testcase>

    Note, that the unit tests provide a commandline flag for verbose benchmark output -vb. However this does not file the time attribute neither.

    N.b. I'm using Qt 4.7.3 on an i386 Linux computer.

    [EDIT: code formatting, please use @-tags, Volker]

  • I know it's an old thread, but did you/somebody managed to make QTestLib work with Jenkins.

    I'm having some problems implementing a simple GuiTest (that uses QTestLib) in Jenkins. In a terminal I can execute the following command:

    @./tst_testgui -xunitxml > testresult.xml@

    This command generates the following .xml file:

    @<?xml version="1.0" encoding="UTF-8" ?>
    <testsuite errors="0" failures="0" tests="3" name="TestGui">
    <property value="5.0.2" name="QTestVersion"/>
    <property value="5.0.2" name="QtVersion"/>
    <testcase result="pass" name="initTestCase"/>
    <testcase result="pass" name="testGui"/>
    <testcase result="pass" name="cleanupTestCase"/>

    In Jenkins I'm trying to do the same by executing the same command in an Execute Shell, but after building the project (works fine) and then executing de command:

    @./tst_testgui -xunitxml > testresult.xml@

    I get the following message in Jenkins:

    QXcbConnection: Could not connect to display
    Aborted (core dumped)
    Build step 'Execute shell' marked build as failure
    Finished: FAILURE

    Does somebody know what could be the problem?

    Grtz. Niels

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should have rather opened a new thread. This one, as you said, is quiet old, and your problem is not related (except for the use of jenkins)

    The error means that your application could not connect to the graphic server. Does you jenkins machine have one ?

  • Hi SGaist,

    thnx for your reply. Next time I will make a new thread.

    I'm running Jenkins (for the moment) on my localhost and I don't know if I have a graphic server.
    Where can I check if I'm using a graphic server in Jenkins?

    BTW: There is an empty testresult.xml generated in de workspace folder.


  • Lifetime Qt Champion

    You're welcome !

    Since you opened this "thread":http://qt-project.org/forums/viewthread/31484/ i'll continue there

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.