Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package hello.tests

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import hello.getHelloString

class FooTest : FunSpec({
test("testFailure") {
getHelloString() shouldBe "Hello, world!"
}

test("testSuccess") {
getHelloString() shouldBe "WRONG!"
}
})
22 changes: 22 additions & 0 deletions kotlinlib/test/src/mill/kotlinlib/HelloWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ object HelloWorldTests extends TestSuite {
ivy"org.jetbrains.kotlin:kotlin-test-junit:${this.kotlinVersion()}"
)
}
object kotest extends KotlinTests with TestModule.Junit5 {
override def ivyDeps = super.ivyDeps() ++ Agg(
ivy"io.kotest:kotest-runner-junit5-jvm:5.9.1"
)
}
}
object main extends Cross[MainCross](kotlinVersions)
}
Expand Down Expand Up @@ -68,6 +73,23 @@ object HelloWorldTests extends TestSuite {
)
})
}
test("kotest") {
val eval = testEval()

HelloWorldKotlin.main.crossModules.foreach(m => {
val Right(discovered) = eval.apply(m.kotest.discoveredTestClasses)
assert(discovered.value == Seq("hello.tests.FooTest"))

val Left(Result.Failure(_, Some(v1))) = eval.apply(m.kotest.test())

assert(
v1._2(0).fullyQualifiedName == "hello.tests.FooTest",
v1._2(0).status == "Success",
v1._2(1).fullyQualifiedName == "hello.tests.FooTest",
v1._2(1).status == "Failure"
)
})
}
test("failures") {
val eval = testEval()

Expand Down
12 changes: 6 additions & 6 deletions testrunner/src/mill/testrunner/TestRunnerUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala
.flatten
)
}
// I think this is a bug in sbt-junit-interface. AFAICT, JUnit is not
// meant to pick up non-static inner classes as test suites, and doing
// so makes the jimfs test suite fail
//
// https://stackoverflow.com/a/17468590
.filter { case (c, f) => !c.isMemberClass && !c.isAnonymousClass }

testClasses
}
Expand Down Expand Up @@ -109,12 +115,6 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala

val runner = framework.runner(args.toArray, Array[String](), cl)
val testClasses = discoverTests(cl, framework, testClassfilePath)
// I think this is a bug in sbt-junit-interface. AFAICT, JUnit is not
// meant to pick up non-static inner classes as test suites, and doing
// so makes the jimfs test suite fail
//
// https://stackoverflow.com/a/17468590
.filter { case (c, f) => !c.isMemberClass }

val tasks = runner.tasks(
for ((cls, fingerprint) <- testClasses.iterator.toArray if classFilter(cls))
Expand Down
Loading