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. [Closed]How to get the information from QTestLib/QTest on test failure.
Forum Updated to NodeBB v4.3 + New Features

[Closed]How to get the information from QTestLib/QTest on test failure.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 3.4k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Sam
    wrote on last edited by
    #1

    Hi,
    I am using QTestLib Library and QTest for running my unit tests. I am working on windows 7 and using Qt 4.8 |MVSC 2010 compiler.
    When i run my test using
    QTest::qExec(TestDateDD/whateverTestClass);

    i get the output in the console :
    @
    ********* Start testing of TestDateDD *********
    Config: Using QTest library 4.8.0, Qt 4.8.0
    PASS : TestDateDD::initTestCase()
    PASS : TestDateDD::testValidity()
    FAIL! : TestDateDD::testMonth(2012/7/10) Compared values are not the same
    Actual (date.longMonthName(date.month())): July
    Expected (monthname): June
    ..\UnitTestingPlugiin\TestDateDD.cpp(38) : failure location
    PASS : TestDateDD::cleanupTestCase()
    Totals: 3 passed, 1 failed, 0 skipped
    ********* Finished testing of TestDateDD *********@

    My requirement is to set some parameter's/message in my Application/Ui if the test has failed. How can i seperate or get the information if the test fails.

    @if(test_failed)
    {
    qdebug()<<"UnSuccessful";
    }
    else
    {
    qdebug()<<"Successful";
    }@

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      okay I got how to check if the test has failed using an integer and checking its value like :

      @int result=0;

      result = QTest::qExec(TestDateDD)

      if(result==0)
      {
      QIcon icon(":/Files/Image/tick.png");
      colItem->setIcon(icon);
      }
      else
      {
      QIcon icon(":/Files/Image/error.png");
      colItem->setIcon(icon);
      }@

      but now my requirement is to get the name and details of the test slot that failed and the failure location like

      @
      FAIL! : TestDateDD::testMonth(2012/7/10) Compared values are not the same
      Actual (date.longMonthName(date.month())): July
      Expected (monthname): June
      ..\UnitTestingPlugiin\TestDateDD.cpp(38) : failure location@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        I did some initial search and found "qtestlog.cpp":http://qt.gitorious.org/qt/qt/blobs/HEAD/src/testlib/qtestlog.cpp that uses a messageHandler. Is the any way to access this messageHandler while running out QTest::qExec() function. I also found "this":https://bugreports.qt-project.org/browse/QTBUG-525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

        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