function WorkAllocator::sortTestsByTypeAndCount

Same name and namespace in other branches
  1. main core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php \Drupal\TestTools\TestRunner\WorkAllocator::sortTestsByTypeAndCount()

Sort tests by test type and count of tests to be executed.

Tests with several methods take longer to run than tests with a single method all else being equal, so this allows tests runs to be sorted by approximately the slowest to fastest tests. Tests that are exceptionally slow can be added to the '#slow' group so they are placed first in each test run regardless of the number of methods.

Parameters

TestClassInfoList $tests: The tests to sort.

1 call to WorkAllocator::sortTestsByTypeAndCount()
WorkAllocator::process in core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php
Allocates tests to workers.

File

core/tests/Drupal/TestTools/TestRunner/WorkAllocator.php, line 130

Class

WorkAllocator
Allocates available tests to test workers.

Namespace

Drupal\TestTools\TestRunner

Code

private function sortTestsByTypeAndCount(array &$tests) : void {
  uasort($tests, fn(array $a, array $b): int => $this->getTestTypeWeight($b['name']) <=> $this->getTestTypeWeight($a['name']) ?: $b['tests_count'] <=> $a['tests_count']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.