Skip to content

Commit 0b1f66b

Browse files
Improve test docs
1 parent be6c858 commit 0b1f66b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

java-runtime/src/test/kotlin/io/spine/validate/ValidatingOptionFactorySpec.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
package io.spine.validate
2828

2929
import io.kotest.matchers.collections.shouldBeEmpty
30+
import io.kotest.matchers.shouldBe
3031
import io.spine.validate.option.ValidatingOptionFactory
3132
import java.util.function.Function
3233
import org.junit.jupiter.api.BeforeEach
3334
import org.junit.jupiter.api.DisplayName
3435
import org.junit.jupiter.api.Test
3536
import org.junit.jupiter.api.assertDoesNotThrow
3637

37-
@DisplayName("Interface `ValidatingOptionFactory` should")
38+
@DisplayName("`ValidatingOptionFactory` should")
3839
internal class ValidatingOptionFactorySpec {
3940

4041
private lateinit var options: ValidatingOptionFactory
@@ -44,14 +45,19 @@ internal class ValidatingOptionFactorySpec {
4445
options = object : ValidatingOptionFactory {}
4546
}
4647

48+
/**
49+
* Verifies that [ValidatingOptionFactory] does not force the classes that
50+
* implement this interface to provide implementations for the methods.
51+
*
52+
* The interface has all the methods declared as `default` providing the implementations.
53+
*
54+
* This test checks that the requirement is met by providing the simplest possible
55+
* implementation via an anonymous object. If this test compiles, we're good to go.
56+
*/
4757
@Test
4858
fun `have no abstract methods`() {
49-
// We do not expect the code below to throw.
50-
// Here we test that the simplest derived class does not implement
51-
// any method and compiles.
52-
assertDoesNotThrow {
53-
object : ValidatingOptionFactory {}
54-
}
59+
val factory = object : ValidatingOptionFactory {}
60+
factory.forBoolean().size shouldBe 0
5561
}
5662

5763
@Test

0 commit comments

Comments
 (0)