Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Output of QTestLib unit-tests: "time"-attribute in testcase-element when using -xunitxml
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foehlisc
    wrote on 25 May 2011, 12:52 last edited by
    #1

    Hi everybody,

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

    http://jenkins-ci.org

    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:

    i)
    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:
    http://ant.1045680.n5.nabble.com/schema-for-junit-xml-output-td1375274.html
    https://gist.github.com/959290

    ii)
    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">
    <properties>
    <property value="4.7.3" name="QTestVersion"/>
    <property value="4.7.3" name="QtVersion"/>
    </properties>
    <testcase result="pass" name="initTestCase"/>
    <testcase result="pass" name="toUpper"/>
    <testcase result="pass" name="toLower"/>
    <testcase result="pass" name="usleepBenchmark">
    </testcase>
    <testcase result="pass" name="cleanupTestCase"/>
    <system-err/>
    </testsuite>
    @

    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]

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nielske87
      wrote on 16 Aug 2013, 14:28 last edited by
      #2

      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">
      <properties>
      <property value="5.0.2" name="QTestVersion"/>
      <property value="5.0.2" name="QtVersion"/>
      </properties>
      <testcase result="pass" name="initTestCase"/>
      <testcase result="pass" name="testGui"/>
      <testcase result="pass" name="cleanupTestCase"/>
      <system-err/>
      </testsuite>@

      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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 16 Aug 2013, 20:32 last edited by
        #3

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • N Offline
          N Offline
          Nielske87
          wrote on 20 Aug 2013, 06:47 last edited by
          #4

          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.

          Niels

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 20 Aug 2013, 21:33 last edited by
            #5

            You're welcome !

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved