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 6 can't use classes from test in integration-test #13107

Closed
mattlong-finocomp opened this issue Aug 11, 2023 · 5 comments · Fixed by grails/grails-gradle-plugin#216
Closed

Comments

@mattlong-finocomp
Copy link

Expected Behavior

I have a trait in src/test that contains some helper methods that have been useful in classes in src/integration-test.
In previous versions of Grails I could implement the trait on my integration-test Spec classes.

Actual Behaviour

compileIntegrationTestGroovy failed compilation as it can't resolve the class from src/test

Steps To Reproduce

  1. use a generated rest-api profile (profile might not matter, but rest-api is what i used) project from start.grails.org
  2. Create a Trait class in src/test/groovy named TestHelper
  3. Create an integration Spec in src/integration-test/groovy and attempt to implement the TestHelper class created previously - This works in Grails 5.3.3 and earlier but not in 6.0.0

Environment Information

  • OS: Pop!OS 22.04
  • Java: 11

Example Application

No response

Version

6.0.0

@jeffscottbrown
Copy link
Member

See the project at https://github.com/jeffbrown/integrationtraitdemo.

src/main/groovy/com/demo/SomeTrait.groovy

package com.demo

trait SomeTrait {
}

src/integration-test/groovy/com/demo/MySpec.groovy

package com.demo

import grails.testing.mixin.integration.Integration
import spock.lang.Specification

@Integration
class MySpec extends Specification implements SomeTrait {

    void "test something"() {
        expect:
        true
    }
}

Does that build and run in your environment?

Thank you for your feedback!

@jeffscottbrown
Copy link
Member

FYI... At jeffscottbrown/integrationtraitdemo@50fb864 I renamed the trait to use the name specified in the initial report above in case there was something going on related to the name "*Helper".

@jeffscottbrown
Copy link
Member

I see now that the report calls for putting the trait in src/test/, not src/main. I expect that is the relevant bit.

@mattlong-finocomp
Copy link
Author

Yes, having the trait in src/main is fine. The regression is only on classes in src/test. This trait in particular is not something i'd want to end up in the production jar so it wouldn't make sense for us to put it in src/main.

@mattlong-finocomp
Copy link
Author

@puneetbehl Can you provide any estimate on when there might be a 6.0.1 (or 6.1.0) grails release, or at the very least a release of the grails-gradle-plugin so that this fix can be used?

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

Successfully merging a pull request may close this issue.

2 participants