What is the best way to test using grails using IDEA?

Posted by egervari on Stack Overflow See other posts from Stack Overflow or by egervari
Published on 2010-05-20T09:50:27Z Indexed on 2010/05/20 10:00 UTC
Read the original article Hit count: 329

I am seriously having a very non-pleasant time testing using Grails. I will describe my experience, and I'd like to know if there's a better way.

  1. The first problem I have with testing is that Grails doesn't give immediate feedback to the developer when .save() fails inside of an integration test. So let's say you have a domain class with 12 fields, and 1 of them is violating a constraint and you don't know it when you create the instance... it just doesn't save. Naturally, the test code afterward is going to fail.

This is most troublesome because the thingy under test is probably fine... and the real risk and pain is the setup code for the test itself.

So, I've tried to develop the habit of using .save(failOnError: true) to avoid this problem, but that's not something that can be easily enforced by everyone working on the project... and it's kind of bloaty. It'd be nice to turn this on for code that is running as part of a unit test automatically.

  1. Integration Tests run slow. I cannot understand how 1 integration test that saves 1 object takes 15-20 seconds to run. With some careful test planning, I've been able to get 1000 tests talking to an actual database and doing dbunit dumps after every test to happen in about the same time! This is dumb.

  2. It is hard to run all the unit tests and not integration tests in IDEA.

  3. Integration tests are a massive pain. Idea actually shows a GREEN BAR when integration tests fail. The output given by grails indicates that something failed, but it doesn't say what it was. It says to look in the test reports... which forces the developer to launch up their file system to hunt the stupid html file down. What a pain.

Then once you got the html file and click to the failing test, it'll tell you a line number. Since these reports are not in the IDE, you can't just click the stack trace to go to that line of code... you gotta go back and find it yourself. ARGGH!@!@!

Maybe people put up with this, but I refuse. Testing should not be this painful. It should be fast and painless, or people won't do it.

Please help. What is the solution? Rails instead of Grails? Something else entirely? I love the Grails framework, but they never demo their testing for a reason. They have a snazzy framework, but the testing is painful.

After having used Scala for the last 1.5 months, and being totally spoiled by ScalaTest... I can't go back to this.

© Stack Overflow or respective owner

Related posts about grails

Related posts about testing