jeudi 15 mars 2018

split a test in different functions with pytest

I'm using pytest and have multiple tests to run to check an issue.

I would like to split all tests in differents functions like this:

# test_myTestSuite.py

@pytest.mark.issue(123)
class MyTestSuite():

    def test_part_1():
        result = do_something()
        assert result == True

    def test_part_2():
        result = do_an_other_something()
        assert result == 'ok'

of course I implemented issue in conftest.py

# conftest.py

def pytest_addoption(parser):
    group = parser.getgroup('Issues')

    group.addoption('--issue', action='store',
                    dest='issue', default=0,
                    help='')

but I don't know how to hook once after tesing MyTestSuite and check that all tests of MyTestSuite correctly passed.

Have someone an Idea ?

PS: this is my first post on stackoverflow.

Aucun commentaire:

Enregistrer un commentaire