dmcg/minutest

Please re-add the @TestFactory feature again

bastman opened this issue · 3 comments

In 0.26, I was able to create a TestClass with different methods. Some where annotated with @testfactory, others with @test.

It looks like the newer versions of minutest, no longer support this style of defining TestClasses. Is there any chance, to get this feature back?

Example:

internal class SomeRepoTest(
        @Autowired private val repo: SomeRepo
) : BootWebMockMvcTest() {
    companion object : KLogging(), SomeApiTestUtils

    @Test
    fun someTest() { ... }

   @TestFactory
    fun someTestFactory() = junitTests<Unit> { ... }

   @TestFactory
    fun anotherTestFactory() = junitTests<Unit> { ... }

}

dmcg commented

It's still there, just a little hidden in order to support a common model with JUnit4!

The new incantation

@TestFactory fun someTestFactory() = rootContext<Unit> {
}.toTestFactory()

Come and join us on the Kotlin Slack - you would have seen instructions for migrating as the changes happened. https://kotlinlang.slack.com/messages/CCYE00YM6

A nice. thank you :) Could you please add it to the docs?

dmcg commented

I'm conflicted TBH. Given the very different fixture lifecycles I'd rather people didn't mix @test and @testfactory. If you want to support multiple minutest root contexts in the same class you can now do that just by defining multiple public methods that return the result of rootContext().