admin管理员组文章数量:1421272
I'm using pytest to run tests across three different environments, and using markers to control which test cases are being executed during a test run.
To optimize the process, I'm using a session-scoped fixture to handle the program's startup, which takes a few minutes. This ensures the program starts only once per test run.
Since I can switch environments freely once the program is running, I want to execute all tests in one environment, then switch to the next environment and rerun the same tests, all within the same pytest session.
Ideally, this would look like:
- Execute a test run, defining which test cases to run utilizing marks
- Program startup happens
- Run the selected test cases in environment 1
- All test cases finish running
- Switch to environment 2
- Re-run the selected test cases
- All test cases finish running
- Switch to environment 3
- ... and so on...
- Program teardown happens
Also, to avoid hardcoding, I need a way to configure the test run to execute in any number of environments without modifying the test code itself.
Is this possible within a single pytest session? What approaches or features could help me achieve this?
本文标签: pythonPytest Rerun tests in the same session after changing environmentsStack Overflow
版权声明:本文标题:python - Pytest: Rerun tests in the same session after changing environments? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745347195a2654543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论