如何知道python selenium + testrail中的特定测试失败

时间:2016-10-31 18:40:01

标签: python selenium testrail

我遇到了逻辑问题。我有一个带有Selenium Python + TestRails的测试套件。当测试失败时,所有后续测试也会失败(即使是未失败的测试)。我知道原因,我的问题是找到解决方案。

我正在使用这种方法:

if self._resultForDoCleanups.failures:
        result_flag = False
elif self._resultForDoCleanups.errors:
        result_flag = False
else:
        result_flag = True

resultForDoCleanups.failures和errors kepp以前执行的代码中的旧东西。 我想知道是否有办法清理此实例或其他解决方案。

我的套房很简单:

suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(excluirServico))
suite.addTest(unittest.makeSuite(exportarGravacoes))
unittest.TextTestRunner().run(suite)

感谢帮助人员。

1 个答案:

答案 0 :(得分:0)

我对您的问题的理解是,您希望以每个测试报告为单独的通过/失败的方式执行测试。

我想你想做点什么:

runner = unittest.TextTestRunner()
suites_to_execute = (excluirServico, exportarGravacoes)
for suite_to_execute in suites_to_execute:
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(suite_to_execute))
    result = runner.run(suite)      
    # code to add the above individual result to testrail is to be called below

请注意makeSuite is obsolete and you should be using the TestLoader().loadTestsFrom* methods instead

相关问题