-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathImpactedTestEngine.kt
More file actions
58 lines (45 loc) · 2.02 KB
/
ImpactedTestEngine.kt
File metadata and controls
58 lines (45 loc) · 2.02 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.teamscale.test_impacted.engine
import com.teamscale.test_impacted.commons.LoggerUtils.createLogger
import com.teamscale.test_impacted.engine.options.TestEngineOptionUtils
import org.junit.platform.engine.*
import org.junit.platform.engine.support.descriptor.EngineDescriptor
import java.util.*
/** Test engine for executing impacted tests. */
class ImpactedTestEngine : TestEngine {
private var internalImpactedTestEngine: InternalImpactedTestEngine? = null
override fun getId() = ENGINE_ID
override fun discover(
discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId
): TestDescriptor {
val engineOptions = TestEngineOptionUtils
.getEngineOptions(discoveryRequest.configurationParameters)
if (!engineOptions.enabled) {
return EngineDescriptor(uniqueId, ENGINE_NAME)
}
if (engineOptions.partition == null) {
throw AssertionError("Agent option partition is undefined, but it's a mandatory parameter when executing impacted tests.")
}
val configuration = engineOptions.testEngineConfiguration
val engine = InternalImpactedTestEngine(configuration, engineOptions.partition)
// Re-initialize the configuration for this discovery (and optional following execution).
internalImpactedTestEngine = engine
return engine.discover(discoveryRequest, uniqueId)
}
override fun execute(request: ExecutionRequest) {
// According to the TestEngine interface the request must correspond to the last execution request. Therefore, we
// may re-use the configuration initialized during discovery.
// Engine might be null if it is not enabled.
internalImpactedTestEngine?.execute(request)
}
override fun getGroupId() = Optional.of("com.teamscale")
override fun getArtifactId() = Optional.of("impacted-test-engine")
companion object {
/** The id of the [ImpactedTestEngine]. */
const val ENGINE_ID = "teamscale-test-impacted"
/** The human readable name of the [ImpactedTestEngine]. */
const val ENGINE_NAME = "Teamscale Impacted Tests"
/** Logger instance */
val LOG = createLogger()
}
}