- Don't ever put @Integration in a test super-class. Only use this in the concrete test classes.
- IDEA needs the tests to be marked with @Test to run in the IDEA/JUnit world. Gradle can still run them, but the IDEA JUnit system misses them.
- Don't use @Rollback together with .withTransaction{} in most cases. The .withTransaction{} gets rolled back too.
- Unit Tests need to use the save(flush:true)syntax now.
- For GEB testing of GUIs, never use @Transaction. Instead use .withTransaction{} to create records. The test code will not commit until it exits the method, so the server will never see the data while the test method is running.
- To test a controller in an integration test, you will need to send an HTTP request to the running server. I use HTTPClient for this. A login is needed to do this (similar to GEB, but at the pure HTTP level, no GUI).
- application.groovy is needed for custom GORM data types. The application.yml does not support the grails.gorm.default.mapping.user-type syntax needed for a custom user type.
(The last one is not test related, but I did not want to create a new blog post for it :).
No comments:
Post a Comment