• internal This class is not covered by the backward compatibility promise for PHPUnit
public PHPUnit\Runner\TestSuiteSorter::ORDER_DEFAULT = 0
  • var int
public PHPUnit\Runner\TestSuiteSorter::ORDER_DEFECTS_FIRST = 3
  • var int
public PHPUnit\Runner\TestSuiteSorter::ORDER_DURATION = 4
  • var int
public PHPUnit\Runner\TestSuiteSorter::ORDER_RANDOMIZED = 1
  • var int
public PHPUnit\Runner\TestSuiteSorter::ORDER_REVERSED = 2
  • var int
public PHPUnit\Runner\TestSuiteSorter::ORDER_SIZE = 5

Order tests by @size annotation 'small', 'medium', 'large'

  • var int
public __construct(?PHPUnit\Runner\TestResultCache $cache = NULL)
public getExecutionOrder() : array
public getOriginalExecutionOrder() : array
public static getTestSorterUID(PHPUnit\Framework\Test $test) : string
  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
public reorderTestsInSuite(PHPUnit\Framework\Test $suite, int $order, bool $resolveDependencies, int $orderDefects, bool $isRootTestSuite = true) : void
private PHPUnit\Runner\TestSuiteSorter::DEFECT_SORT_WEIGHT = [4 => 6, 3 => 5, 6 => 4, 2 => 3, 5 => 2, 1 => 1, -1 => 0]

List of sorting weights for all test result codes. A higher number gives higher priority.

private PHPUnit\Runner\TestSuiteSorter::SIZE_SORT_WEIGHT = [1, 2, 3, -1 => 4]
private $cache
private $defectSortOrder
  • var array Associative array of (string => DEFECT_SORT_WEIGHT) elements
private $executionOrder
  • var string[] A list of normalized names of tests affected by reordering
private $originalExecutionOrder
  • var string[] A list of normalized names of tests before reordering
private addSuiteToDefectSortOrder(PHPUnit\Framework\TestSuite $suite) : void
  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
private calculateTestExecutionOrder(PHPUnit\Framework\Test $suite) : array
  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
private cmpDefectPriorityAndTime(PHPUnit\Framework\Test $a, PHPUnit\Framework\Test $b) : int

Comparator callback function to sort tests for "reach failure as fast as possible":

  1. sort tests by defect weight defined in self::DEFECT_SORT_WEIGHT
  2. when tests are equally defective, sort the fastest to the front
  3. do not reorder successful tests
  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
private cmpDuration(PHPUnit\Framework\Test $a, PHPUnit\Framework\Test $b) : int

Compares test duration for sorting tests by duration ascending.

  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
private cmpSize(PHPUnit\Framework\Test $a, PHPUnit\Framework\Test $b) : int

Compares test size for sorting tests small->medium->large->unknown

private getNormalizedDependencyNames( $test) : array
  • return string[] A list of full test names as "TestSuiteClassName::testMethodName"
private randomize(array $tests) : array
private resolveDependencies(array $tests) : array

Reorder Tests within a TestCase in such a way as to resolve as many dependencies as possible.

The algorithm will leave the tests in original running order when it can.
For more details see the documentation for test dependencies.

Short description of algorithm:

  1. Pick the next Test from remaining tests to be checked for dependencies.
  2. If the test has no dependencies: mark done, start again from the top
  3. If the test has dependencies but none left to do: mark done, start again from the top
  4. When we reach the end add any leftover tests to the end. These will be marked 'skipped' during execution.
  • return (\DataProviderTestSuite|\TestCase)[]
private reverse(array $tests) : array
private sort(PHPUnit\Framework\TestSuite $suite, int $order, bool $resolveDependencies, int $orderDefects) : void
private sortByDuration(array $tests) : array
private sortBySize(array $tests) : array
private sortDefectsFirst(array $tests) : array
private suiteOnlyContainsTests(PHPUnit\Framework\TestSuite $suite) : bool
public static getTestSorterUID(PHPUnit\Framework\Test $test) : string
  • throws SebastianBergmann\RecursionContext\InvalidArgumentException
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only