-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
How to parameterize the entire test suite? #3196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Usually this is done by parametrizing a fixture which is used by some/all your tests, for example: @pytest.fixture(params=['firefox', 'chrome', 'IE']
def browser(request):
return request.param Now every test which requests |
Wouldnt this cause a staggered behaviour though? Test A - Firefox Instead of what i want which is Test A - Chrome... |
pytest will automatically reorder session-scoped fixtures to avoid creating/destroying them too much, so it will execute in the order you want. 😁 |
I'm closing this for now @Drew-Ack, but feel free to post further question. |
is it possible to make it work with dependencies, where you depend on the depency called with the same fixture value. currently we depend on function name, but that breaks, as the fixture value becomes part of the signature. |
@sjpotter Using the same fixture multiple times during a test will give you the same (cached) value. I don't really follow though, do you have an example? |
something like this (though this isn't quite) @pytest.fixture(scope="session", params=[False, True])
def tags(request):
return request.param
class TestTestyMcTester
@pytest.mark.dependency()
def test_create_database(self, tags):
....
@pytest.mark.dependency(depends=["TestTestyMcTester::test_create_database"])
def test_database_services(self, tags):
.... perhaps not the best way to do it, but until I removed the depends lines, it is skipping all those tests as they don't match (I think) because the fixture changes the signature. when I remove them, the tests run as I expect (i.e. test_create_database(False) -> test_database_service(Fales) -> test_create_database(True) -> test_database_service(True), but would prefer that dependency handling was still there (i.e. all my test functions with proper dependencies) |
I guess whatever |
ah, ok, I thought it was part of core pytest, apparently it isn't, hence when figuring out how to do it, found this. will investigate |
I want to be able to have pytest run the test suite in firefox, then chrome, then IE. All in one swoop.
I know its possible to parameterize test functions, but i'm not sure if this is possible to do on a test suite level.
Is this possible to do in pytests scope?
The text was updated successfully, but these errors were encountered: