在QtCreator中重复执行Qt测试的测试结果

问题描述

我正在使用带有QtCreator 4.6.1的Qt Test进行单元测试。

我的简单测试类如下。

#include <QString>
#include <QtTest>
#include "../MyApplication/pen.h"

class MyApplicationTest : public QObject
{
    Q_OBJECT

public:
    MyApplicationtest();

private Q_SLOTS:
    void testPenSetValue();
    void testPenSetValue2();
};

MyApplicationTest::MyApplicationtest()
{
}

void MyApplicationTest::testPenSetValue()
{
    Pen* p = new Pen();
    p->setValue(5);

    QCOMPARE( p->getValue(),5 );
}

void MyApplicationTest::testPenSetValue2()
{
    Pen* p = new Pen();
    p->setValue(5);
    QCOMPARE( p->getValue(),5 );
}


QTEST_APPLESS_MAIN(MyApplicationTest)

#include "tst_myapplicationtest.moc"

但是似乎测试执行了两次。通过一次测试,我得到了如下结果。

Starting C:\Users\Lakshan\Documents\MyApplicationTest_Build\debug\tst_myapplicationtest.exe...
********* Start testing of MyApplicationTest *********
Config: Using QTest library 4.8.4,Qt 4.8.4
PASS   : MyApplicationTest::initTestCase()
PASS   : MyApplicationTest::testPenSetValue()
PASS   : MyApplicationTest::testPenSetValue2()
PASS   : MyApplicationTest::cleanupTestCase()
Totals: 4 passed,0 Failed,0 skipped
********* Finished testing of MyApplicationTest *********
********* Start testing of MyApplicationTest *********
Config: Using QTest library 4.8.4,0 skipped
********* Finished testing of MyApplicationTest *********
C:/Users/Lakshan/Documents/MyApplicationTest_Build/debug/tst_myapplicationtest.exe exited with code 0

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...