Overview

Commit 3c2dfebf4ec5e9d791c1f3c9fa0ad35a5a9fcd6b introduced a new expectAll() method in WebTestClient in order to support soft assertions.

We should investigate options for improving the developer experience with a Kotlin DSL.

Related Issues

  • 27317

Comment From: sbrannen

@simonbasle, since you implemented #29727, I have assigned this to you as a followup.

Comment From: simonbasle

Having looked into it a bit, I don't think there is any improvement we can provide with Kotlin extension methods, unlike the expectBody class of extensions already in place.

I was not able to produce a better experience with extensions than the following Kotlin usage of the java expectAll method with SAM:

val exchange = WebTestClient
        .bindToRouterFunction( router { GET("/") { ok().bodyValue("foo") } } )
        .build()
        .get().uri("/").exchange()
        .expectAll(
                { it.expectStatus().isNotFound },
                { it.expectHeader().contentLength(200) },
                { it.expectBody().isEmpty }
        )

Unlike the Mock MVC side, there's no full blown parallel Kotlin DSL to work with here and I don't think it's worth exploring for the sake of soft assertions when the above works perfectly well.

I have an idea for an alternative way of doing soft assertions, but for the java side so that's another story.