It seems that due to recursive generics in BodySpec interface
and due to expectBody method returns
WebTestClient cannot be used in Kotlin.
Kotlin inherits the result of .expectBody(Person::class.java) as BodySpec<Person, *> and thus the following methods in chain cannot be constructed due to the following error:
Error:(25, 20) Kotlin: Type inference failed: Not enough information to infer parameter T in fun <T : Nothing!> isEqualTo(p0: Controller.Person!): T!
Please specify it explicitly.
And it applies only Nothing as a type parameter.
But in this case generated bytecode contains the following line
If you work with list the situation is a bit better - Kotlin still cannot inherit type param automatically but you can specify it explicitly due to method expectBodyList in interface ListBodySpec doesn't return wildcards
Full example with java and kotlin can be found here.
Tests in java works well in these cases.