1
votes

What is the difference during the integration phase of running grails tests via grails test-app vs grails test-app -integration

I have a set of tests that will pass under one but not the other but I can't seem to find what is different in the integration phase based on the two ways to call it.

2
Jeff, by any chance the tests that fail when running grails test-app are using properties from the GrailsConfig class? - Maricel
Not that I see directly. - Jeff Beck
I had had the same problem with the integration tests when using GrailsConfig, it is like if the unit tests clear the object and the integration ones don't reload it again before starting, so what I did was to use default values and that "fixed" it. - Maricel

2 Answers

3
votes

unit tests in grails run without the environment being set up. There is no database; objects and the gorm are mocked, and you need to do specific things to set up the domain objects for testing. And you can't do things like test hql based queries (I think that feature might be coming in newer versions of grails)

Integration tests are completely different. You bootstrap code is run, and all db calls go to an actual running database (which you can configure in datasources if you want it to be different). If you call a service method from an integration test, it will go to the db, with transactions and everything else. Also, The Spring bean autowiring/dependency injection step is run, so all your services are fully wired up and ready to go.

Thats a general outline, without seeing the tests and the failures, its hard to say whats wrong.

2
votes

I've had a similar problem. I'm not sure why, but the order of integration tests was different. This lead to an error during setUp/tearDown. Basically one tearDown had some issues and didn't remove all objects which were created in setUp. This lead to an error in the next test.

Worth checking.