1.
Script Example:
Execution Result:
2.
Script Example:
Execution Result:
The order of execution can be seen from the above:
The following conclusions can be drawn broadly:
1) The order of the tests is generally carried out in the order of the modules-----
2) then according to the test case name in ascending order, such as test_square than test_sub first execution;
3) When a test module contains both a test function and a test class, it must be the setup (if defined) that executes the teardown (if defined) after the module test isexecuted. Also , the setup and Setdown of the module are executed only once .
4) Each test method in the test class executes the setup (if defined) before execution, and executes the teardown (if defined). And the execution of each test method is the same, and the new method is executed again in the order->teardown the Setup-> execution method.
Above example Execution Order: module setup-Class 1setup--Class 1 Method-Class 1teardown-class 1setup-Class 1 Method-Class 1teardown-(class 2setup)-Class 2 Method-(class 2teardown)-module Method- Module teardown
In a function or functional use case organization, setup and teardown are executed only once, starting and ending respectively.
Python--nose Instance Example