Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running single integration test quickly in Grails

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

like image 680
Prakash Avatar asked May 25 '10 11:05

Prakash


People also ask

What is the best time to perform integration testing?

Usually, integration testing is done after unit testing to ensure all the units work in harmony with each other. It is also done when support libraries are used along with the code.

How soon can we start integration testing?

A QA engineer starts testing after all modules are assembled into a wholesome system or at least its major part. It means that integration testing starts when code writing is finished and the first version of a product is ready for the release.

Is jest good for integration testing?

Jest is a popular unit test framework that can easily be extended to include integration tests.


2 Answers

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.

like image 144
Dónal Avatar answered Nov 16 '22 02:11

Dónal


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, as the name implies.

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

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

coverage {
    enabledByDefault = false
}
like image 33
Daniel Engmann Avatar answered Nov 16 '22 02:11

Daniel Engmann