我是使用Google测试框架的新手,仍然需要大量 Material 来充分利用它。

有什么办法可以指示/指定测试用例之间的关系,以便可以有条件地执行它?可以说我有两个测试;如果第一个测试成功,是否可以运行第二个测试?我不是很确定它是否属于测试“单元”的原始规则,但是我只是想知道它是否可能。

最佳答案

没有办法在源代码中做到这一点。可能的解决方案使用 shell 程序脚本,并使用过滤器运行测试。

Python示例:

from subprocess import call

def runTest(pattern):
    return call(['test', '--gtest_filter=%s' % pattern])

if runTest('FirstPriorityTestPattern') == 0:
   return runTest('SecondPriorityTestPattern')
return 1

关于c++ - Google测试框架-测试用例之间的依赖性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12741404/

10-11 23:21
查看更多