Breakfast: rerun defects first#3147
Closed
epdenouden wants to merge 1 commit into
Closed
Conversation
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use case
Rerun defective unit tests first to speed up the red-green-refactor cycle!
Test results and timings are shared between tests runs using a cache. This allows for sorting defective tests to the front of the execution order using an additional sorter. This new sort option is compatible with existing test ordering options.
This project is a followup to my previous work on reordering test execution. The code is available in my Breakfast development branch.
Summary of changes
TestSuiteSortergains the ability to sort suites and tests by priority of defects and execution timeResultCacheExtensionto gather result and timing information during test runsTestResultCachefor sharing of result state between runs--cache-resultand configuration attributecacheResult='true'--order-by=defectsand configuration attributeexecutionOrder='defects'--cache-result-fileand configuration attributecacheResultFileHow to test
To activate storing the results of a run use
--cache-result:For this example we switch the cache on for every run by adding the attribute
cacheResult="true"to the<phpunit>element inphpunit.xml.Break
TestCaseTestby running it backwards:Look at the cache file. By default this is
.phpunit.result.cachein the PHPUnit working directory.Break
TestCaseTestagain with the sorting feature turning on:The skipped tests are still there but are run immediately now, but still fail. This is easily avoided by asking the sorter to keep dependencies in mind:
Design considerations
Like the New Order feature the aim is for a robust system with sane defaults that silently does its work and is easily maintained by other developers:
cacheResult="true"to your configuration and it silently does its work.