In a pure Kotlin project I am using JUnit Jupiter 5.5.2 and AssertJ 3.10.0. The following test executes successful:
@Test
fun `Validates something`() = runBlocking {
try {
// Assert something
} catch (t: Throwable) {
fail("Should not throw $t")
}
}
Once I update to AssertJ 3.11.1 the test build fails with this message:
Type inference failed: Not enough information to infer parameter T in fun fail(p0: String!): T!
Please specify it explicitly.
If I use fail<Nothing>("Should not throw $t")
then No test were found
.
I tried to figure out what's going on - without success though.
It seems the problem is with the runBlocking
expression body. If you turn it into a block body, then it would work no matter which type you use to specify on the fail
method (using Nothing
as an example, which can be Any
, Any?
or any other types):
@Test
fun `Validates something`() {
runBlocking {
try {
// Assert something
} catch (t: Throwable) {
fail<Nothing>("Should not throw $t")
}
}
}