-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvalTest.kt
31 lines (26 loc) · 930 Bytes
/
EvalTest.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
import com.github.michaelbull.result.unwrap
import facade.extractDynamicTests
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.Test
private fun List<DynamicTest>.matchRegex(regex: Regex): List<DynamicTest> =
this.filter { it.displayName.matches(regex) }
private fun List<DynamicTest>.executeAll() = forEach { it.executable.execute() }
class EvalTest {
private val dynamicTests =
extractDynamicTests("src/test/kotlin/Sum.kt").unwrap()
@Test
fun `must not fail`() {
dynamicTests.matchRegex("sum.*".toRegex()).executeAll()
}
@Test
fun `must fail`() {
dynamicTests.matchRegex("Const.*".toRegex()).forEach { test ->
try {
test.executable.execute()
Assertions.fail("${test.displayName} should've thrown.")
} catch (_: Throwable) {
}
}
}
}