Groovy

Groovy programming language tutorials, examples, and best practices.

Groovy Spock Testing – Getting Started with 12+ Tested Examples

Groovy testing with Spock Framework. 12+ examples covering given/when/then, data-driven testing, mocking, stubbing, exception testing, @Unroll. Groovy 5.0.6. “Code without tests is bad code.” Michael Feathers, Working Effectively with Legacy Code Last Updated: July 2026 | Tested on: Groovy 5.0.6, Spock 2.4, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 25 minutes Testing is one of those things every developer knows they should do, but too often the testing framework itself gets in the way. Verbose setup, cryptic ... Read More

Groovy Type Checking – @TypeChecked and @CompileStatic with 10 Examples

Groovy type checking with @TypeChecked and @CompileStatic. 10+ examples covering type safety, performance, migration from dynamic Groovy. Groovy 5.0.6. “Groovy gives you the freedom to be dynamic when you want and static when you need. The trick is knowing when each one makes sense.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate to Advanced | Reading Time: 24 minutes One of Groovy’s biggest selling points is its flexibility — you can write fully dynamic ... Read More

Groovy Generics and Type Parameters – 13 Tested Examples

Groovy generics and type parameters with 13 examples. Covers generic classes, methods, bounded types, wildcards, @CompileStatic. Groovy 5.0.6. “Generics are the seatbelts of type safety – you don’t always feel them, but they save you when things go wrong.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate to Advanced | Reading Time: 25 minutes If you’ve ever worked with typed collections in Java, you already know what Groovy generics look like on the surface. ... Read More