我正在使用Qt Test,用于某些计算繁重算法的写入单元测试。该过程使用了相当长的时间,并且当在较旧的计算机中运行时,该过程失败,因为这样的超时:
********* Start testing of KnotTest *********
Config: Using QtTest library 5.6.2, Qt 5.6.2 (i386-little_endian-ilp32 shared (dynamic) release build; by MSVC 2013)
PASS : MyTest::initTestCase()
QFATAL : MyTest::test_benchmark() Test function timed out
FAIL! : MyTest::test_benchmark() Received a fatal error.
Unknown file(0) : failure location
Totals: 1 passed, 1 failed, 0 skipped, 0 blacklisted
********* Finished testing of KnotTest *********
如何为生成的测试程序设置自定义超时?
答案 0 :(得分:4)
您可以使用名为QTEST_FUNCTION_TIMEOUT
的环境变量覆盖超时。必须以毫秒为单位指定超时。默认情况下,Qt使用超时300000毫秒(5分钟)。
此环境变量未记录,因此我无法保证它将继续出现在Qt的未来版本中。
另外,您可以使用qputenv
以编程方式设置环境变量:
答案 1 :(得分:3)
在QtCreator中,您可以更改
中的默认超时工具 - >选项 - >测试 - >一般:超时
另请参阅以下链接中的“构建和运行测试”: