Skip to content

Instantly share code, notes, and snippets.

@bastman
Last active December 19, 2019 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastman/b8f3d9656f936ab7e6dd0c4eb9ddca3f to your computer and use it in GitHub Desktop.
Save bastman/b8f3d9656f936ab7e6dd0c4eb9ddca3f to your computer and use it in GitHub Desktop.
kotlin-minutest: the missing docs ... how to use @testfactory
// 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