隨著自動化測試的 case 越來越多,總有一天會遇到該來平行跑測試這件事。
根據使用的框架、CI/CD 工具不同,實作方式也會有所差異。這邊紀錄一下我之前用 pytest mark
搭配 GitHub Actions 做平行執行的做法。
mark
拿來執行一系列 case 很方便,所以放在 Github Actions 時,決定以 matrix 同時開多個同 mark 名稱的節點來執行,類似下面這樣:strategy:matrix:mark: ['node_serviceA', 'node_serviceB', 'node_serviceC']fail-fast: false
run: pytest -m ${{ matrix.mark }}
@pytest.mark.node_serviceAdef test_api_service_a():#...