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
Expected Behavior
I should be able to use
GrailsWebMockUtil.bindMockWebRequest()in a test without explicitly addingorg.springframework:spring-testto thetestCompileClasspath.Actual Behaviour
java.lang.NoClassDefFoundError: org.springframework.mock.web.MockHttpServletRequestThis is because
org.springframework:spring-testis acompileOnlydependency ongrails-web-commonso it is not available for consumers, which is correct as we don't want a dependency onorg.springframework:spring-testin consumers production dependencies.This is what the Gradle
java-test-fixturesplugin 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
GrailsWebMockUtilto a separate project.Steps To Reproduce
No response
Environment Information
No response
Example Application
No response
Version