Search code examples
grailsquartz-schedulersts-springsourcetoolsuite

Spring Tool Suite Grails integration test unable to resolve class for Quartz job


I have a Grails 2.3.11 project using the Quartz plugin, with a job defined in grails-app/jobs/mypkg

package mypkg

class DoStuffJob {

    static triggers = {
      simple repeatInterval: 5000l // execute job once in 5 seconds
    }

    def execute() {
        /* do stuff */
    }
}

To test this job, I created an integration test in test/integration

package mypkg

...

@TestMixin(IntegrationTestMixin)
class DoStuffJobTests {

    def doStuffJob

    @Before
    void setup() {
        doStuffJob = new DoStuffJob()
    }

    @After
    void cleanup() {
    }

    @Test
    void "DoStuffJob"() {
        doStufFJob.execute()
    }
}

This test runs correctly and passes, but the Spring Tool Suite IDE has an error "Groovy:unable to resolve class DoStuffJob" in my test's setup() method.

This causes STS to prompt me about errors in the workspace whenever I launch the project, and also causes ugly red X's in Project Explorer.

Why is STS showing this error, and how do I fix it?


Solution

  • Add grails-app/jobs as a source folder by right-clicking on it and selecting Build Path | Use as Source Folder.