Detect flaky test and retry on failure using pytest
Preconditions (2)
Step 1: Create a test function that randomly fails
Step 2: Add a decorator to retry the test up to 3 times on failure
Step 3: Run the test suite
Step 4: Observe if the test retries when it fails
Step 5: Verify the test passes if it succeeds within retries or fails after retries
β
Expected Result: The flaky test retries up to 3 times on failure and passes if any retry succeeds; otherwise, it fails after all retries.