Test suite stops after first failure
Hi there! I'm working on a test automation project using pytest-check and I'm running into a behavior I don't quite understand.
What I want to achieve:
- When a test case fails (using check.fail() or check.equal()), I want that specific test case to stop
- The teardown for that test case should run
- Then the test suite should continue with the next test case
What's happening instead:
- When maxfail=1 (default), the entire test suite stops after the first failure
- When maxfail=0, it continues but doesn't stop the current test case
Here's a simple example of what I'm trying to do:
def test_case_1():
check.equal(1, 2) # This fails
# More code that shouldn't run - Perform teardown
check.equal(3, 3) # This shouldn't run
def test_case_2():
check.equal(4, 4) # This should run even if test_case_1 failed
Is this behavior intentional? If so, is there a recommended way to get the behavior I'm looking for? I'm using pytest-check 2.5.2 with pytest 7.4.4.
Thanks for your help!
Looks like you want the default assert behavior. The main point of this plugin is to allow checks to cause a test to fail but not stop a test at the point of failure.
Does this do what you want?
def test_case_1():
assert 1 == 2 # This fails
# More code that shouldn't run - Perform teardown
assert 3 == 3 # This shouldn't run
def test_case_2():
assert 4 == 4 # This should run even if test_case_1 failed
If it does, then you don't need this plugin. :)
Assume thumbs up meant that last comment answered question. Closing