Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate Kotlin DSL options for expectAll() in WebTestClient #27318

Closed
sbrannen opened this issue Aug 23, 2021 · 2 comments
Closed

Investigate Kotlin DSL options for expectAll() in WebTestClient #27318

sbrannen opened this issue Aug 23, 2021 · 2 comments
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply theme: kotlin An issue related to Kotlin support

Comments

@sbrannen
Copy link
Member

sbrannen commented Aug 23, 2021

Overview

Commit 3c2dfeb 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

@sbrannen sbrannen added in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Aug 23, 2021
@sbrannen sbrannen added this to the 5.3.10 milestone Aug 23, 2021
@snicoll snicoll modified the milestones: 5.3.10, 5.3.11 Sep 14, 2021
@sbrannen sbrannen modified the milestones: 5.3.11, 5.3.12 Oct 12, 2021
@jhoeller jhoeller modified the milestones: 5.3.12, 5.3.13 Oct 18, 2021
@jhoeller jhoeller modified the milestones: 5.3.13, 6.0.x Nov 1, 2021
@sdeleuze sdeleuze added the theme: kotlin An issue related to Kotlin support label Jan 19, 2022
@sbrannen
Copy link
Member Author

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

@sbrannen sbrannen assigned simonbasle and unassigned sdeleuze Jan 24, 2023
@simonbasle simonbasle added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement labels Jan 25, 2023
@simonbasle simonbasle removed this from the 6.0.x milestone Jan 25, 2023
@simonbasle
Copy link
Contributor

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.

@simonbasle simonbasle closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply theme: kotlin An issue related to Kotlin support
Projects
None yet
Development

No branches or pull requests

5 participants