Good morning <@U0E2MNCPN>! I'm trying to get minut...
# minutest
d
Good morning @dmcg! I'm trying to get minutest up in a microservice, but I'm getting no tests found...
Copy code
Testing started at 10:53 AM ...
> Task :cleanTest
> Task :kaptGenerateStubsKotlin UP-TO-DATE
> Task :kaptKotlin UP-TO-DATE
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :kaptGenerateStubsTestKotlin
> Task :kaptTestKotlin
w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor (NON_INCREMENTAL), javaslang.match.PatternsProcessor (NON_INCREMENTAL).
> Task :compileTestKotlin
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test FAILED
~~~ Project Configuration ~~~
-> Parallelism: 1 thread
-> Test order: LexicographicSpecExecutionOrder
-> Soft assertations: False
-> Write spec failure file: False
-> Fail on ignored tests: False
-> Extensions
  - io.kotlintest.extensions.SystemPropertyTagExtension
  - io.kotlintest.extensions.RuntimeTagExtension
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [controller.SomeManagerControllerTest](filter.includeTestsMatching)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 4s
9 actionable tasks: 5 executed, 4 up-to-date
With JUnit5
d
You’re extending JUnit5Minutests? Try putting a plain old @Test fun in the same class and see if that is run
d
Yes, I extended that. and even old
@Test
doesn'
doesn't work
I had kotlintest there too, so maybe it's causing problems?
d
Then I’d say you have a bigger problem than minutest! Is all the junit engine stuff in place in your Gradle build?
d
Copy code
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.1")

    testImplementation("io.kotlintest:kotlintest-runner-junit5:3.4.1")

    testImplementation("org.junit.jupiter:junit-jupiter-api:5.3.2")
    testImplementation("dev.minutest:minutest:1.11.0")
    testImplementation("io.strikt:strikt-core:0.24.0")
    testImplementation("io.mockk:mockk:1.9.3")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.3.2")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.3.2")
Copy code
val test by tasks.getting(Test::class) {
    useJUnitPlatform { }
}
In kotlin dsl
d
I know that Kotlintest has some issue - can you try without it
d
still not working 😧
I don't really know what this means:
No tests found for given includes: [controller.SomeManagerControllerTest](filter.includeTestsMatching)
Do I need some extra configs?
It seems like Intellij has junit jupiter (api/engine) 5.6.0, platform (commons/engine/launcher) 1.6.0 in its dependency list (newer than what you have on the site), could that be the problem?
oops wrong import for
@Test
...
Looks like kotlintest was the problem... but it's still funny that intellij shows
minutests()[1][1]
as the
test
name...
Is there a bug in gradle 6.2.2 for getting test names @dmcg?
d
Between JUnit and Gradle yes. If you run tests in IntelliJ with the IntelliJ runner not the Gradle runner they show up ok
for me!
d
Ok thanks, I'll give it a try!
It works nicely 😃 ! But is there any way to get rid of the extra minutests() nesting?
d
There is the Minutest engine!
d
?
d
@natpryce wrote an engine that uses the JUnit 5 test discovery but not runner. Maybe he can explain how to use it?
n
The MinutestEngine plugs into the JUnit runner, giving you nested tests and suites
The TestEngine API is the “official” way to extend JUnit 5 for different test frameworks
d
So how is it used with Minutest?
n
You need to tell one of the layers of JUnit 5 to use the Minutest engine. You can configure it in Gradle. Also in the IntelliJ test runner config dialog.
In gradle you add the config :
Copy code
useJunitPlatform {
   includeEngines("junit-jupiter", "junit-vintage", "minutest")
}
to your junit config block
However, it’s experimental so be warned it may not do everything you need. It could do with someone to look after it hint hint :-D
d
Right now, I have that config without includeEngines inside, it still runs the tests but includes:
Copy code
TestClass
|_ minutest()
   |_Context
     |_Test
minutest() looks a bit funny there and wastes one indenting.
n
That looks like the JUnit5 support. The minutest engine expects tests to be written as top-level functions.
d
You mean just
Copy code
fun someClassTest() = rootContext {
...
}
at the top level?
with no class around it
n
Yes
It had to be annotated I recall
Let me take a look on GitHub to remind myself
No, no annotations needed.
The test engine picks up top-level function that return a root context
d
Nice 😃! So what kind of quirks could there be here?
n
Not sure. I’ve not worked on Minutest for quite a long time, and Duncan has focused on the JUnit5 Jupiter integration rather than the test engine.
It might be that you need to annotate functions to get IntelliJ to recognise them as tests in the code editor
d
Ok, thanks!
d
Yes, getting IntelliJ to recognise them as runnable was the block I stumbled over last night
n
If you run all the tests, then you can run individual tests from the tree of tests in the IntelliJ test runner (which is an improvement on when running Minutest from JUnit 5 or JUnit 4).
d
I think that I did get that working for JUnit5
Sorry 😉
n
Even for tests within subcontexts?
d
I think so, away from non-bank computer ATM
n
I recall that annotating top-level functions with
@Testable
made IntelliJ treat them as runnable test methods
(And I assume any annotation that is itself meta-annotated with
@Testable
would work)
d
Oooh - let me have a look at that (in my copious free time)