views:

262

answers:

2

Is it possible to quickly run single/all integration test in a class quickly in Grails. The test-app comes with heavy baggage of clearing of all compiled files and generating cobertura reports hence even if we run single integration test, the entire code base is compiled,instrumented and the cobertura report is getting generated. For our application this takes more than 2 minutes.

If it was possible to quickly run one integration test and get a rapid feedbck, it would be immensely helpful.

Also, is it important to clean up all the compiled files once the test is complete? This cleaning is fine if we run the entire set of integration test, but if we are going to run one or two tests in a class this cleaning and re-compiling seems to be a big bottleneck for quicker feedback to developers.

Thanks

+1  A: 

It is the intention of the integration test to do this whole compiling, data base creation, server starting, etc. because the tests should run in an integrated environment, s the name implies.

Maybe you can extract some tests to unit tests. These you can run in Eclipse.

You can switch off Coberture by placing the following code in your grails-app/conf/BuildConfig.groovy:

coverage {
    enabledByDefault = false
}
Daniel Engmann
The cobertura infact had the problem. We were using the cobertura plugin and the plugin cleaned up all the compiled sources after the report was generated, this prevented us from exploiting all the benefit associated with incremental compilation. Moreover, running one or two test doesn't require a comprehensive cobertura report for us and the integration test ran quickly once we disabled it. Thanks for the pointer.
Prakash
+1  A: 

If you have an integration test class

class SimpleControllerTests extends GrailsUnitTestCase {
    public void testLogin() {}
    public void testLogin2() {}
    public void testLogin3() {}
}

You can run just one test in this class using:

grails test-app integration: SimpleController.testLogin

However, you will still have to incurr the time penalty required for integration testing (loading config, connecting to DB, instantiating Spring beans, etc.)

If you want your tests to run quickly, then try to write unit tests rather than integration tests.

Don
The running one test example works for, just need the full path to the Class though
Bill Comer