-
Notifications
You must be signed in to change notification settings - Fork 623
/
topLevelTests.kt
34 lines (28 loc) · 1.01 KB
/
topLevelTests.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.kotlintest.internal
import io.kotlintest.Project
import io.kotlintest.Spec
import io.kotlintest.TestCase
import io.kotlintest.TestCaseOrder
import io.kotlintest.extensions.TopLevelTest
/**
* Returns the top level [TestCase]s to run, in the order they
* should be run.
*
* Takes into account focused tests, which can override
* the active/inactive behavior defined in [isActive].
*/
fun topLevelTests(spec: Spec): List<TopLevelTest> {
val order = spec.testCaseOrder() ?: Project.testCaseOrder()
val tests = when (order) {
TestCaseOrder.Sequential -> spec.testCases()
TestCaseOrder.Random -> spec.testCases().shuffled()
}
val focused = tests.find { it.name.startsWith("f:") }
// if we have no focused tests, then we default to the standard is active logic
// otherwise focused overrides
return if (focused == null) {
tests.map { TopLevelTest(it, isActive(it)) }
} else {
listOf(focused).map { TopLevelTest(it, true) } + tests.minus(focused).map { TopLevelTest(it, false) }
}
}