Setup and teardown methods¶
Test suites provide several methods that give the user the possibility to execute code at particular steps of the suite execution:
setup_suite()
is called before executing the tests of the suite; if something wrong happens (a call tolog_error
or a raised exception) then the whole suite execution is abortedsetup_test(test)
takes the test instance as argument and is called before each test, if something wrong happen then the test execution is abortedteardown_test(test, status)
is called after each test, it takes the test instance as argument and the status of the test “so far”, if something wrong happens the executed test will be mark as failedteardown_suite()
is called after executing the tests of the suite
Note
- code within
setup_suite
andteardown_suite
methods is executed in a dedicated context and the data it generates (checks, logs) will be represented the same way as a test in the test report - code within
setup_test
andteardown_test
methods is executed within the related test context and the data it generates will be associated to the given test