-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
At first, thank you for pytest. This is great framework for testing with good interface and reporting.
I wanted to separate my test case into steps, for example:
class TestCreateUser(object):
def test_create_user(self, webdriver):
assert True
def test_user_login(self, webdriver):
assert False
def test_user_logout(self, webdriver):
assert True
def test_delete_user(self, webdriver):
assert True
I did it just because it looks nice in report. You know, if one part of scenario fails, you could see which part failed, with no need to read tracebacks.
So, I used code from documentation, and now if one step fails, the next methods will not be executed.
But today I discovered, if methods use parameters or fixture with parameters, weird things starts happening:
test_create_user.py::TestCreateUser::test_create_user[chrome] PASSED test_create_user.py::TestCreateUser::test_user_login[chrome] FAILED test_create_user.py::TestCreateUser::test_user_logout[chrome] xfail test_create_user.py::TestCreateUser::test_delete_user[chrome] xfail
%other tests% PASSED
test_create_user.py::TestCreateUser::test_create_user[firefox] xfail test_create_user.py::TestCreateUser::test_user_login[firefox] xfail test_create_user.py::TestCreateUser::test_user_logout[firefox] xfail test_create_user.py::TestCreateUser::test_delete_user[firefox] xfail
As you can see, if once class method has FAILED state, the next steps will be xfailed even with different param. This is the first bug with this code.
The second bug -- next steps also will be xfailed, if current test have been skipped with @pytest.mark.skip
:
test_create_user.py::TestCreateUser::test_create_user[chrome] PASSED test_create_user.py::TestCreateUser::test_user_login[chrome] SKIPPED test_create_user.py::TestCreateUser::test_user_logout[chrome] xfail test_create_user.py::TestCreateUser::test_delete_user[chrome] xfail
I tried to fix first bug manually, but I don't know well pytest API. Eventually, I decided not to use incremental testing at all.
...but I'll be glad if you fix this code in future releases.
My testing environment is: Python 3.6.3, pytest-3.3.2, py-1.5.2, pluggy-0.6.0