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

Add support for Spring-Boot 1.4 @SpringBootTest annotation #581

Closed
kiview opened this Issue Apr 30, 2016 · 11 comments

Comments

Projects
None yet
5 participants
@kiview

kiview commented Apr 30, 2016

Spring-Boot 1.4 will introduce a new annotation for test classes called @SpringBootTest to avoid some of the integration test boilerplate annotations. See boot-features-testing-spring-boot-applications and Testing improvements in Spring Boot 1.4

Currently the spock-spring plugin does not recognize this annotation in order to identify this class as a Spring test class and instead relies on other annotations like @ContextHierarchy or @ContextConfiguration which do not need to be present if @SpringBootTest used.

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Apr 30, 2016

I'm working on this in #582.

kiview commented Apr 30, 2016

I'm working on this in #582.

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview May 16, 2016

The other new annotations like @DataJpaTest or @WebMvcTest are not supported as well. What would be a good strategy to identify Spring instead of looking for specific annotations? This seems to be a bit unstable.

kiview commented May 16, 2016

The other new annotations like @DataJpaTest or @WebMvcTest are not supported as well. What would be a good strategy to identify Spring instead of looking for specific annotations? This seems to be a bit unstable.

@szpak

This comment has been minimized.

Show comment
Hide comment
@szpak

szpak Jun 1, 2016

Contributor

@kiview Do you have a proposal how the implementation could look like?

Contributor

szpak commented Jun 1, 2016

@kiview Do you have a proposal how the implementation could look like?

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Jun 2, 2016

I'll try to look into Spring-Boot and see if I can find a more stable element to look for inside the classpath. I think checking for @BootstrapWith(SpringBootTestContextBootstrapper.class) might work.

kiview commented Jun 2, 2016

I'll try to look into Spring-Boot and see if I can find a more stable element to look for inside the classpath. I think checking for @BootstrapWith(SpringBootTestContextBootstrapper.class) might work.

@kiview kiview closed this Jun 2, 2016

@kiview kiview reopened this Jun 2, 2016

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Jun 23, 2016

I think I got it working by looking for an annotation which class itself is annotated with @BootstrapWith. I'll check if it works for all test annotations now and I'll submit an PR afterwards.

kiview commented Jun 23, 2016

I think I got it working by looking for an annotation which class itself is annotated with @BootstrapWith. I'll check if it works for all test annotations now and I'll submit an PR afterwards.

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Jun 23, 2016

The PR is #610.
Right now it seem's, the new Spring-Boot tests have broken JDK6 compatibility, I'll look into that.

kiview commented Jun 23, 2016

The PR is #610.
Right now it seem's, the new Spring-Boot tests have broken JDK6 compatibility, I'll look into that.

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Jun 24, 2016

It's working now.

kiview commented Jun 24, 2016

It's working now.

robfletcher added a commit that referenced this issue Jul 5, 2016

Merge pull request #610 from kiview/spring-boot-1.4
Fixed #581 by adding complete Spring-Boot 1.4 support
@alexejk

This comment has been minimized.

Show comment
Hide comment
@alexejk

alexejk Jul 26, 2016

I believe there might still be an issue with @WebMvcTest, specifically when providing a controller with constructor arguments. Spring Boot documentation uses mockito and @MockBean however this won't work with Spock. While Spock does provide Mock() support it would seem that they are not being registered correctly.

alexejk commented Jul 26, 2016

I believe there might still be an issue with @WebMvcTest, specifically when providing a controller with constructor arguments. Spring Boot documentation uses mockito and @MockBean however this won't work with Spock. While Spock does provide Mock() support it would seem that they are not being registered correctly.

@kiview

This comment has been minimized.

Show comment
Hide comment
@kiview

kiview Jul 26, 2016

@alexejk Could you open a dedicated issue for this problem? Your explanation makes sense, but I think we need a special implementation for the @WebMvcTest annotation, since a bit more logic and plumbing is involved here.

The current solution simply restores Spock's Spring integration functionality to work like before Spring-Boot 1.4. The problem with @WebMvcTest however is an enhancement of the existing functionality I'd say.

I'd like to look into this problem as well, did you already look into the code? I'm not entirely sure yet if we can rework the existing behavior to work correctly with Spock or if we need a dedicated annotation, like @SpockWebMvcTest.

kiview commented Jul 26, 2016

@alexejk Could you open a dedicated issue for this problem? Your explanation makes sense, but I think we need a special implementation for the @WebMvcTest annotation, since a bit more logic and plumbing is involved here.

The current solution simply restores Spock's Spring integration functionality to work like before Spring-Boot 1.4. The problem with @WebMvcTest however is an enhancement of the existing functionality I'd say.

I'd like to look into this problem as well, did you already look into the code? I'm not entirely sure yet if we can rework the existing behavior to work correctly with Spock or if we need a dedicated annotation, like @SpockWebMvcTest.

@alexejk

This comment has been minimized.

Show comment
Hide comment
@alexejk

alexejk Jul 26, 2016

Sorry, should've thought about the separate issue.
Have not yet had a chance to see exactly what is happening - just spent time yesterday trying to make it work and found out it doesn't :( Anyways, #624 created for future discussions & tracking.

alexejk commented Jul 26, 2016

Sorry, should've thought about the separate issue.
Have not yet had a chance to see exactly what is happening - just spent time yesterday trying to make it work and found out it doesn't :( Anyways, #624 created for future discussions & tracking.

@robfletcher robfletcher added this to the 1.1-rc-1 milestone Aug 24, 2016

@dg-grow-virgiliu-ratoi

This comment has been minimized.

Show comment
Hide comment
@dg-grow-virgiliu-ratoi

dg-grow-virgiliu-ratoi Sep 16, 2016

it seems to fix the issues that I had in my particular project, thanks.

dg-grow-virgiliu-ratoi commented Sep 16, 2016

it seems to fix the issues that I had in my particular project, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment