lundi 23 novembre 2015

Can't execute Grails unit

I'm trying to upgrade a Grails app from 2.0.3 to 2.5.3. When I try to execute a unit test I get this error

InitializationError: Field $testRuntimeRule must implement MethodRule

@TestFor(ApplicationApiController)
class ApplicationApiControllerTests {

    JobDetail j

    GrailsMock quartzService

    @Before
    void setUp() {
        j = newJob(CallUrlJob.class)
                .withIdentity('someId', 'application')
                .usingJobData("url", "some/url")
                .build()

        quartzService = mockFor(QuartzService, true)
        controller.quartzService = quartzService.createMock()
    }

    @Test
    void listApplications() {
        quartzService.demand.listGroups { ->
            ['application', 'different']
        }

        controller.listApplications()
        assert response.status == 200
    }
}

It seems the error is occurring before the @Before method is executed. Some Googling suggests the source of problem may be some JUnit version incompatibility, but I'm struggling to find a remedy.

Aucun commentaire:

Enregistrer un commentaire