str0zzapreti / pytest-retry

A simple plugin for retrying flaky tests in CI environments
MIT License
27 stars 6 forks source link

Retry timings flag #1

Closed str0zzapreti closed 1 year ago

str0zzapreti commented 1 year ago

Added a new flag to select from two different duration modes. The default is now overwrite, where the last run's duration is written to the final report and all other attempt durations are discarded. This should help with time-based splitting algorithms such as CircleCI's and result in more even splits for fully passing runs.

The original behavior is now available by passing the 'cumulative' option to the flag instead

Additionally, attaching arbitrary attributes to the test item is frowned upon in the Pytest docs, so instead, two new stash keys have been created to store and retrieve each item's attempt count and whether it passed or failed. These two values can be used to determine the outcome matrix for any test item: i.e. whether it passed, failed, passed with retries or failed with retries.

New unit tests have been added to validate the additional functionality.