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

Slice tests don't work with WebFlux/reactive model #11230

Closed
asarkar opened this issue Dec 1, 2017 · 2 comments
Closed

Slice tests don't work with WebFlux/reactive model #11230

asarkar opened this issue Dec 1, 2017 · 2 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@asarkar
Copy link

asarkar commented Dec 1, 2017

Problem Description
Looks like most of the "slice" tests described in section 41.3.5 Auto-configured tests don't work with the WebFlux or reactive model.

@WebMvcTest looks for controllers, and doesn't find RouterFunction and RouterFunction. Even if a @RestController is made for WebFlux, it fails looking for Servlet-specific classes (I don't remember the exact error).

@DataMongoTest has no knowledge of ReactiveCrudRepository and such.

@RestClientTest only configures RestTemplateBuilder, not WebClient.

Rant
Matter of fact, I've seen this problem with every major release. When Spring 3 was released, Java config was not fully ready, but was announced as a game changer. With Spring 4, Groovy support was a biggie, but it took couple of minor versions to get it working in idiomatic manner (like bean definitions in Groovy). With Spring 5, reactive model is hyped, but existing test framework doesn't fully support it. I understand why new features may be good fodder for elevator pitches, but it's very frustrating when the shiny new things actually have rust underneath.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2017
@philwebb philwebb mentioned this issue Dec 1, 2017
@philwebb
Copy link
Member

philwebb commented Dec 1, 2017

@asarkar Your rant is unhelpful and unwelcome in the issue tracker. Like most software projects we have limited time and resources. We're doing the best that we can.


To address your issues:

@WebMvcTest looks for controllers, and doesn't find RouterFunction and RouterFunction. Even if a @RestController is made for WebFlux, it fails looking for Servlet-specific classes (I don't remember the exact error).

@WebMvcTest is indeed tied to the Servlet API and it won't find RouterFunction beans since they are part of WebFlux. You probably want to try @WebFluxTest rather than @WebMvcTest. I'm not sure if we have RouterFunction support with that annotation or not. If you find it doesn't work, please open a new dedicate issue (we prefer that each issue focuses on a single problem, rather than have one issue reporting several things).

@DataMongoTest has no knowledge of ReactiveCrudRepository and such.

I don't know what this means, please open a new issue with a more complete description along with a sample application that we can clone and run.

@RestClientTest only configures RestTemplateBuilder, not WebClient.

Correct, this annotation is designed to mock server calls for RestTemplateBuilder. It makes no sense for it to configure a WebClient.

@philwebb philwebb closed this as completed Dec 1, 2017
@philwebb philwebb added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 1, 2017
@snicoll
Copy link
Member

snicoll commented Dec 1, 2017

I'm not sure if we have RouterFunction support with that annotation or not.

We don't and there is #10683 for that

@DataMongoTest has no knowledge of ReactiveCrudRepository and such.

No idea what that means but @DataMongoTest works with reactive repositories

@restclienttest only configures RestTemplateBuilder, not WebClient.

What Phil said. There is also an issue in Spring Framework to update RestTemplateBuilder to work with the web client. Once we have that, we'll be able to offer support in @RestTestClient and we have #8404 for that.

@asarkar a more positive way would be to come up with pull requests or dedicated issues with a technical analysis rather than dumping the stuff you want that doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants