【问题标题】:How to use QtTest with qbs如何将 QtTest 与 qbs 一起使用
【发布时间】:2017-09-14 04:41:41
【问题描述】:

我找不到使用 qbs 构建测试的明确示例。 我试过这样

import qbs

CppApplication {
  consoleApplication: true

  files: [ "TestTask.h", "TestTask.cpp" ]
  Depends { name: "Qt"; submodules: [ "core", "testlib" ] }
}

TestTask 是一个 QObject 子类。 但是编译器说我错过了 main() 函数。

【问题讨论】:

标签: qt qbs qttest


【解决方案1】:

为了编译测试你需要main.cpp。例如:

#include <QCoreApplication>
#include <QTest>
#include "TestTask.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QTest::qExec(new TestTask, argc, argv);
    return 0;
}

您还必须在文件(qbs 文件)中添加 main.cpp。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 2018-08-25
    • 1970-01-01
    • 2023-03-13
    • 2014-09-25
    • 2016-01-30
    • 2015-12-13
    相关资源
    最近更新 更多