Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我找不到使用 qbs 构建测试的明确示例。我试过这样
import qbs CppApplication { consoleApplication: true files: [ "TestTask.h", "TestTask.cpp" ] Depends { name: "Qt"; submodules: [ "core", "testlib" ] } }
TestTask 是一个 QObject 子类。但是编译器说我错过了 main() 函数。
对于编译测试,您需要 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。