python - Pytest: Rerun tests in the same session after changing environments? - Stack Overflow

I'm using pytest to run tests across three different environments, and using markers to control wh

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:

  1. Execute a test run, defining which test cases to run utilizing marks
  2. Program startup happens
  3. Run the selected test cases in environment 1
  4. All test cases finish running
  5. Switch to environment 2
  6. Re-run the selected test cases
  7. All test cases finish running
  8. Switch to environment 3
  9. ... and so on...
  10. 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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745347195a4623608.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信