Skip to main content

Posts

Showing posts with the label groovy

Advantages and Disadvantages using Groovy for Unit Test (JUnit)

I'm collecting the advantages and disadvantages using Groovy for JUnit and found following interesting stuffs... Advantages: You don't need to implement inner classes which are very awful and bloat your test codes. Instead you can use closures . Using closures for writing your mock objects can make your test codes smaller and more compact ! File operations are very easy to implement thanks to AntBuilder . How many times do you need to make some file operations (delete, mkdir, ...) within your test codes? Doing this with java.io is not fun at all. Using AntBuilder for this purpose is a good thing, since Ant is predestinated to do this job. If you think that you could do the same thing in pure Java, you will find that this takes a lot more work. Using Ant directly in Java is unfortunately not straight forward. Example: to use the unzip Ant task you need to use the Expand Java class, which is not documented properly (so you need to dig into the Java source code). In Ant...