Home > other >  About the unittest. TestSuite
About the unittest. TestSuite

Time:10-17

Everyone a great god, and in a recent study of unittest testing framework, I would like to ask about unittest. TestSuite problem, I use unittest TestSuite modified test case execution order, but don't work, or in accordance with the ASCII code 0-9 & gt; A - Z> To execute, a to z order
The code is as follows:
If __name__=="__main__ ':
Suite=unittest. TestSuite ()
Test_is_prime test_cases=[TestMyfunc (" "), TestMyfunc (" test_add "), TestMyfunc (" test_devide ")]
Suite. AddTests (test_cases)
# test
Runner=unittest. TextTestRunner (verbosity=2)
Runner. The run (suite)
Execution of the order should be: TestMyfunc (" test_is_prime "), TestMyfunc (" test_add "), TestMyfunc (" test_devide "),
But code to run the result is: test_add, test_devide test_is_prime such order
Asking our great god under the guidance of

CodePudding user response:

try addTest
Code=python]
Def suite () :
Suite=unittest. TestSuite ()
Suite. AddTest (BarTestCase (' test_nine))
Suite. AddTest (FooTestCase (' test_ten))
Suite. AddTest (FooTestCase (' test_eleven))
Suite. AddTest (BarTestCase (' test_twelve))
Return suite

[/code]
  • Related