-
Notifications
You must be signed in to change notification settings - Fork 17
/
MutationTestResultTest.scala
57 lines (48 loc) 路 1.56 KB
/
MutationTestResultTest.scala
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
package mutationtesting
class MutationTestResultTest extends munit.FunSuite {
test(
"MutationTestResult should have correct default $schema and schemaVersion"
) {
val sut =
MutationTestResult(thresholds = Thresholds(80, 60), files = Map.empty)
assertEquals(sut.`$schema`.get, "https://git.io/mutation-testing-schema")
assertEquals(sut.schemaVersion, "2")
}
test("FileResult should have default language Scala") {
val sut = FileResult("", Seq.empty)
assertEquals(sut.language, "scala")
}
val validThresholds = List(
(0, 0),
(1, 0),
(0, 1),
(99, 0),
(0, 99),
(100, 0),
(0, 100),
(100, 100)
)
validThresholds.foreach { case (high, low) =>
test(s"Threshold should be valid for high $high low $low") {
Thresholds.create(high, low) match {
case Left(value) => fail(s"Expected valid threshold, got error $value")
case Right(value) =>
assertEquals(value, Thresholds(high = high, low = low))
}
}
}
val invalidThresholds = List(
(101, 0, "thresholds.high should be <= 100"),
(-1, 0, "thresholds.high should be > 0"),
(0, 101, "thresholds.low should be <= 100"),
(0, -1, "thresholds.low should be > 0")
)
invalidThresholds.foreach { case (high, low, expectedErrorMessage) =>
test(s"Threshold should be invalid for high $high low $low") {
Thresholds.create(high, low) match {
case Left(value) => assertEquals(value, expectedErrorMessage)
case Right(value) => fail(s"Expected Left error, got Right $value")
}
}
}
}