Saturday, February 7, 2009

Testing in Grails: common information

Grails supports the concepts of:
  1. Unit testing - testing individual methods or blocks of code without considering for surrounding infrastructure. You have to mock these methods or blocks using something like Groovy Mock or ExpandoMetaClass. Alternatively, you could using the Testing plugin. I will show all 3 approaches in future posts.
  2. Integration testing - you have full access to the Grails environment within the test. Grails will use a database (HSQLDB, MySQL or another found in Grails configuration) for integration tests and clear out all the data from the database in between each test.
  3. Functional testing - involve testing the actual running application. Grails has support for functional testing via Canoo WebTest plug-in.
Also be aware that You have to test all layers of the application:
  1. Domain entities - usually You have to write unit tests for validation process.
  2. Services - usually You have to write unit and integration tests to be sure that services are working properly.
  3. Controllers - usually You have to write unit and integration tests to be sure that controllers are working properly.
We will cover all mentioned tests on real examples for all layers in future posts.

No comments:

Post a Comment