Critical test marker¶
This is example of using the critical marker in pytest-hardpy to control test execution flow.
The @pytest.mark.critical
marker allows to designate tests or entire modules as critical.
If a critical test fails or is skipped, all subsequent tests in the current and following modules will be skipped.
how to start¶
- Launch
hardpy init critical_test
. - Launch CouchDH instance.
- Modify the files described below.
- Launch
hardpy run critical_test
.
test_critical.py¶
import pytest
@pytest.mark.critical
def test_core_feature():
assert False # This will fail
def test_secondary_feature():
assert True # This will be skipped
Output:
test_core_feature
: Failedtest_secondary_feature
: Skipped
test_module_a.py¶
import pytest
pytestmark = pytest.mark.critical
def test_a1():
assert False # Fails
def test_a2():
assert True # Skipped
test_module_b.py¶
def test_b1():
assert True # Skipped because module_a failed
Output:
test_a1
: Failedtest_a2
: Skippedtest_b1
: Skipped