Test Automation with Spock and Geb
4 Days
groovyspockgebbddautomation
testingautomation
Intermediate
testerdeveloper

This intensive workshop coaches participants on how to leverage the power of Groovy to create robust, expressive, and highly readable automated tests. It covers both Spock, the premier testing and specification framework for Java and Groovy applications, and Geb, a developer-friendly browser automation solution.

Participants will learn how to write tests that are not just verifying code, but also acting as living documentation. The program starts with the essentials of the Groovy language required for testing, moves deep into Spock's BDD-style features, mocking, and data-driven testing capabilities, and concludes with mastering Geb for end-to-end web UI automation.

Audience

Program is primarily for developers and software savvy testers who want to build a modern, expressive test automation suite using the Groovy ecosystem.

Prerequisites

Participant must have beginner to intermediate level knowledge of Core Java or any other Object-Oriented programming language. Prior exposure to testing concepts is must.

Topics

Groovy for Testing
  • Introduction to Groovy
  • Groovy vs Java
  • Groovy Setup and Syntax Basics
  • Dynamic Typing and Def
  • Closures (Essential for Spock & Geb)
  • Collections (Lists, Maps) and Iteration
  • Groovy Truth
  • String Interpolation (GStrings)
  • Safe Navigation Operator
  • Using Java Libraries in Groovy
Spock Framework
  • What is Spock?
  • Spock vs JUnit
  • The Anatomy of a Spock Specification
  • Blocks: given, when, then, expect, cleanup, where
  • Fixture Methods (setup, cleanup, setupSpec, cleanupSpec)
  • Assertions in Spock (Implicit Assertions)
  • Exception Testing
  • Data Driven Testing with Data Tables
  • Data Pipes and Unrolling
  • Interaction Based Testing (Mocking & Stubbing)
  • Creating Mocks, Stubs, and Spies
  • Verifying Interactions and Cardinality
  • Returning Values and Throwing Exceptions from Stubs
API & Integration Testing
  • Testing REST APIs with Spock
  • Using Groovy's RESTClient or HTTPBuilder
  • Parsing and Validating JSON/XML Responses
  • Managing Test Data
  • Reporting (Spock Reports Extension)
Geb for UI Automation
  • Introduction to Geb
  • Geb Architecture and WebDriver Integration
  • Configuration (GebConfig.groovy)
  • The Browser Object
  • Interacting with Content (Driving the Browser)
  • Geb's jQuery-like Navigator API ($ function)
  • Finding Elements (CSS Selectors)
  • Asserting Page Content
  • The Page Object Pattern in Geb
  • Defining Pages and Content DSL
  • 'at' Checkers
  • Reusable UI Components
  • Waiting and Asynchronous Content
  • Executing JavaScript
  • Integrating Geb with Spock

Exclusions

Advanced Java/Groovy language features not related to testing, deep dive into specific CI/CD pipeline configurations.

Anything not mentioned in Topics

Software Requirements

Latest IntelliJ IDEA Community Edition
Java Development Kit (JDK) 17 or higher
Modern browser(s) like Chrome, Firefox

Internet Requirements

Good unrestricted internet connection is required.

Hardware Requirements

Laptop capable to run MS Office
Or Modern Developer Laptop

Classroom Requirements

Projector with HDMI, White Board, Markers with Eraser

Online Requirements

Appropriate meeting software e.g. Zoom, MS Teams Please make sure that camera, speaker and mic are working

If you have any query, please contact now.