I've been struggling for a while now trying to get kotlintest tests to run properly from maven. I'm far from a maven expert so I'm hoping someone can tell me where I'm going wrong.
I started with the maven example from the kotlin repo here, and that works fine. The issue arises when more tests are added. When I add more tests (in nested packages), only a single test actually gets "run", the others just seem to have a dummy test method run. For example, given the following hierarchy:
With this pom.xml, running mvn test
gives:
Running BarTest
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE! - in BarTest
should fail Time elapsed: 0.004 sec <<< FAILURE!
java.lang.AssertionError: expected: true but was: false
Running test.BarTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec - in test.BarTest
Running a.AThingTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec - in a.AThingTest
Running newtest.FooTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec - in newtest.FooTest
Results :
Failed tests:
BarTest expected: true but was: false
Tests run: 5, Failures: 1, Errors: 0, Skipped: 0
The very first one: Running BarTest
is actually the right test (and has an intentional failure). All the other ones (Running test.BarTest
, Running a.AThingTest
, Running newtest.FooTest
) aren't actually running my tests (I have intentional failures there too), and appear to be just some dummy tests (perhaps from the dummy @Test
in IntelliTestMarker
?). I included a sample of one of those test files below.
What do I need to do to run all of my actual tests? And, preferably, not have the 'dummy' tests show up in the output?
BarTest.kt:
package test
import io.kotlintest.shouldBe
import io.kotlintest.specs.ShouldSpec
class BarTest : ShouldSpec() {
init {
"Bar" {
should("succeed") {
true shouldBe true
}
should("fail") {
false shouldBe true
}
}
}
}