Skip to content

grails.util.GrailsWebMockUtils should be a testFixture #13836

@matrei

Description

@matrei

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions