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 documentation for the spring module #641
Conversation
eae17e9
to
95c3757
Compare
@Bean | ||
GreeterService serviceMock() { | ||
return mockFactory.Mock(GreeterService) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth documenting that you can also do this?
@Bean public FactoryBean<GreeterService> serviceMock() {
return new SpockMockFactoryBean(GreeterService.class);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this example will add a GreeterService
Bean
to the Spring context?
Since I did not knew this before, I'd love to see this solution mentioned in the docs as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would. I guess it's just a different pattern that doesn't require the DetachedMockFactory
instance. It does exactly the same thing.
Looks good. I think this is a really useful addition to 1.1 as this was super-painful before. |
When testing against a real app, I got caught in a turtles all the way down scenario. I was testing a controller that depended on a service that depended on a repo. The test would fail because the repo wasn’t mocked. Turns out it was mostly caused by us using It’s worth noting in the docs. I’ve updated my example with some notes. |
@snekse I don't know. It is not actually the fault of the |
@snekse As a rule of thumb, you should simply avoid field injection. And using constructor injection has become even easier in Spring-Boot 1.4, since I don't think this behavior needs to be mentioned in the Spock docs. |
No description provided.