Igor
Igor

Reputation: 34021

Grails integration tests fail only when run with 'grails test-app'

When I run my integration test suite with grails test-app -integration, all of the tests pass. However, when I run them with grails test-app, the unit tests pass, but the integration tests fail with the error:

Cannot set readonly property: requestAttributes for class: 
org.springframework.web.context.request.RequestContextHolder

Now, I've searched for all instances of RequestContextHolder and have not been able to find a spot where this is being set by the tests/app.

My question is, what is different between running just the integration tests vs the entire test suite? I've run into instances where tests will fail because say, registerMetaClass was not called in the previous test, but this situation seems different since it's an entire suite.

Upvotes: 2

Views: 1336

Answers (1)

Ted Naleid
Ted Naleid

Reputation: 26821

This sounds like test pollution to me.

I'd try running just one unit test and one integration test. If that fails, switch to a different unit test and see if it still fails. If it runs with just one unit test, it's likely a unit test that's bad and you can start running them in batches with an integration test to see which causes the failure.

The other thing I'd do for this kind of thing, if you've got your project under source control, would be to revert back to a known good version where the tests all passed and make sure they all still run. Could be something in your environment. If it runs, go to a revision half way to the tip and try that. Keep doing a manual binary search till you narrow it down.

Both git and mercurial have a built in feature called "bisect" that lets you hunt for the exact revision that caused the failure without having to manually update. If you're on another RCS it might have something like that too.

Upvotes: 2

Related Questions