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

grails.util.GrailsWebMockUtils should be a testFixture #13836

Open
matrei opened this issue Nov 14, 2024 · 0 comments
Open

grails.util.GrailsWebMockUtils should be a testFixture #13836

matrei opened this issue Nov 14, 2024 · 0 comments

Comments

@matrei
Copy link
Contributor

matrei commented Nov 14, 2024

Expected Behavior

I should be able to use GrailsWebMockUtil.bindMockWebRequest() in a test without explicitly adding org.springframework:spring-test to the testCompileClasspath.

Actual Behaviour

java.lang.NoClassDefFoundError: org.springframework.mock.web.MockHttpServletRequest

This is because org.springframework:spring-test is a compileOnly dependency on grails-web-common so it is not available for consumers, which is correct as we don't want a dependency on org.springframework:spring-test in consumers production dependencies.

This is what the Gradle java-test-fixtures plugin solves. It allows you to separate testFixtures from ordinary classes so you can consume them without getting them in the production classpaths.

Another alternative is to extract GrailsWebMockUtil to a separate project.

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant