-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Introduce soft assertions for WebTestClient #26969
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
Introduce soft assertions for WebTestClient #26969
Conversation
...t/src/test/java/org/springframework/test/web/reactive/server/samples/SoftAssertionTests.java
Outdated
Show resolved
Hide resolved
b97efa4 to
38c6105
Compare
It happens very often that WebTestClient is used in
heavyweight integration tests. It's no use to waste
time to check if another condition has been fixed or
not. Soft assertion could help a lot to check all
conditions at once even if one of them fail.
New API would look like as follows:
```java
client.get().uri("/test")
.exchange()
.expectAllSoftly(
exchange -> exchange.expectStatus().isOk(),
exchange -> exchange.expectBody(String.class)
.isEqualTo("It works!")
);
```
38c6105 to
0b2c503
Compare
|
This PR is blocked until #26917 has been merged into |
It happens very often that WebTestClient is used in heavyweight
integration tests, and it's a hindrance to developer productivity to
fix one failed assertion after another. Soft assertions help a lot by
checking all conditions at once even if one of them fails.
This commit introduces a new expectAllSoftly(..) method in
WebTestClient to address this issue.
client.get().uri("/hello")
.exchange()
.expectAllSoftly(
spec -> spec.expectStatus().isOk(),
spec -> spec.expectBody(String.class).isEqualTo("Hello, World")
);
Closes spring-projectsgh-26969
|
Sorry for the late review. Overall looks good, but I've spotted a follow-up issue to be fixed. Currently individual expectations like I'm not immediately sure how to solve this, but we'll need to find something. |
Good catch.
OK. Let's brainstorm. Maybe we could use a |
It happens very often that WebTestClient is used in heavyweight
integration tests, and it's a hindrance to developer productivity to
fix one failed assertion after another. Soft assertions help a lot by
checking all conditions at once even if one of them fails.
This commit introduces a new expectAllSoftly(..) method in
WebTestClient to address this issue.
client.get().uri("/hello")
.exchange()
.expectAllSoftly(
spec -> spec.expectStatus().isOk(),
spec -> spec.expectBody(String.class).isEqualTo("Hello, World")
);
Closes spring-projectsgh-26969
Overview
It happens very often that
WebTestClientis used in heavyweight integration tests. It's no use to waste time to check if another condition has been fixed or not. Soft assertions could help a lot to check all conditions at once even if one of them fails.Proposal
New API would look like as follows:
Related Issues