0

I got a logic problem. I have a test Suite with Selenium Python + TestRails. When a test fails, all the subsequent tests fails as well(even the tests that does not fails). I know the reason, my problem is found out the solution.

I am using this method:

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

The resultForDoCleanups.failures and errors kepp the old stuff from codes executed before. I want to know if there is a way to clean up this instances or other solution.

My suite is simples:

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

Thanks for the help guys.

Yago
  • 1
  • 1
  • 3

1 Answers1

0

My understanding of your problem is that you want to execute your tests in such a way that each test reports as an individual Pass / Fail.

I think you want to do something like:

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

Note that makeSuite is obsolete and you should be using the TestLoader().loadTestsFrom* methods instead.

testworks
  • 386
  • 1
  • 10