I seen a few posts (for instance here 1) suggesting to use groovy to write integration tests for java applications in groovy programming language. I am working on an application using the following technologies: Java 7, java EE 6, POSTGRESQL
I know groovy is
But is there any particular reason to use it for ITs? Adding another programming language to your codebase would not make your life hell? I think I am missing something from the picture, so I would appreciate your responses.
I will soon start a project with exactly the same stack as yours, but Groovy will also be in production code, not only tests.
There is no problem in adding Groovy to your codebase, because it is an easy language. It'd be a different story if you were including some language which doesn't look a lot like java, say haskell or prolog. You are already including Facelets, EL, CSS, HTML and Javascript. Which part of adding another language is bad? :-)
The main points i pick up for Groovy in IT tests:
Other just-to-cool-to-forget stuff in Groovy:
We had test teams in my two last companies which weren't working in production code, but started writing tests in Groovy pretty quickly and enjoyed the language: no worries about types and stuff, just working tests!
I think it should be read as Groovy is especially good for writing tests compared to Java. There is nothing in Groovy you cannot do in Java, but it would often take tremendous effort. Something like Spock for example, would be near unreadable in Java.
It is many small things that make it so. There are for example power asserts, that make the output of assertion errors from assert statements in Groovy very nice. The seamless integration allows not to have extra code to align the languages worlds. The DSL capabilities allow you easily to write minimal DSLs to reduce the boilerplate code. All this is there to enable you to see what you actually test and how. Because if a test fails, you have to understand that part exactly and it reduces the time you need to spend on writing tests.
All I can advise is trying it out for a bit. It then either convinces you or not. If your cases are very simple, then maybe Java is good enough for you. If the testing gets more complex, then having to understand some Groovy code could be the smaller hurdle here. Not to forget: as a Java developer you don't need to understand all too much about Groovy to be able to use it properly and write nice unit tests with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With