Last active
December 19, 2019 09:05
-
-
Save bastman/b8f3d9656f936ab7e6dd0c4eb9ddca3f to your computer and use it in GitHub Desktop.
kotlin-minutest: the missing docs ... how to use @testfactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see: https://github.com/dmcg/minutest/blob/master/docs/README.md | |
// see: https://github.com/dmcg/minutest/blob/master/docs/installation.md | |
// gradle dependency (jcenter): testImplementation("dev.minutest:minutest:1.9.+") | |
// how to use? | |
class FooTests { | |
@TestFactory | |
fun `some dynamic tests`() = rootContext { | |
test(name="a test") { | |
// asertions | |
} | |
test(name="another test") { | |
// asertions | |
} | |
}.toTestFactory() | |
@TestFactory | |
fun `some other dynamic tests`() = rootContext { | |
test(name="a test") { | |
// asertions | |
} | |
test(name="another test") { | |
// asertions | |
} | |
}.toTestFactory() | |
@TestFactory | |
fun `some other tests`() = minuTestFactory(name="some other tests") { | |
test(name="a test") { | |
// asertions | |
} | |
test(name="another test") { | |
// asertions | |
} | |
} | |
} | |
@JvmName("minuTestFactoryForClass") | |
inline fun <reified F> minuTestFactory( | |
name:String= "root", | |
noinline builder: TestContextBuilder<Unit, F>.() -> Unit | |
): Stream<out DynamicNode> = rootContext(name,builder).toTestFactory() | |
fun minuTestFactory(name:String= "root", builder: TestContextBuilder<Unit, Unit>.() -> Unit): Stream<out DynamicNode> = | |
minuTestFactory<Unit>(name, builder) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment