Course in Spock Testing

Course in writing unit tests using Groovy Spock

Spock is a framework for writing tests targeting both Java and Groovy applications (i.e. JVM languages). It is designed to provide a dedicated DSL (Domain Specific Language) for writing test based on the given/when/then idiom, data tables tests and easy mock object usage.
This is what you will learn
  • Know how to write Spock specifications (a.k.a. tests)
  • Know how to write tests using data tables
  • Know how to wite tests using mock objects
Course Contents

Background and Overview

  • What is unit testing
  • Traditional testing in the Java world
  • Unit testing with Groovy
  • The Spock game changer
  • Installing Spock
  • The Spock web console

Groovy Primer

  • Why Groovy cvan be considered Java++
  • Simpler syntax
  • Groovy data-strycture literals
  • Groovy operators
  • Closures, aka lambda expressions
  • How Groovy improved the Java API

Basic Spock

  • Specifications
  • Structure of a test
  • Setup blocks
  • When/Then blocks
  • Understanding assertion conditions
  • Interpreting failed tests
  • Asserting exceptions

More Spock

  • Expect blocks
  • Fixture methods
  • Cleanup blocks
  • Helper methods

Data-Driven Testing

  • Where blocks
  • Data tables
  • Result columns
  • Unrolling
  • Data pipes

Mock Objects

  • What is a mock object
  • Creating spock mocks
  • Defining interactions
  • Cardinality
  • Constraints
  • Argument matching
  • Verification
  • Stubbing and Stubs


  • Annotations
  • Ignore annotations
  • Requires
  • Stepwise
  • Timeout
  • AutoCleanup
  • Title
NameSpock Testing
Duration1 Days
AudienceJava programmers
PrerequisitesPractical knowledge in Javav programming
  • Groovy
  • Spock
  • JetBrains Intellij IDEA
  • Java JDK, version 8+
Course Dates
2020-02-14Stockholm11 000 kr
2020-03-06Stockholm11 000 kr
2020-03-27 Stockholm11 000 kr
2020-04-17Stockholm 11 000 kr
2020-05-08Stockholm 11 000 kr
2020-05-28Stockholm 11 000 kr

Same-Company Discout

We offer a 20% discount for additional participants from the same company and at the same course date. Read more here.

Teaching Language

Our printed course material is always authored in English. The oral presentation in our classrooms is generally in Swedish, unless all participants agree to that we perform the course in English.

On-Site Course

If you order an On-Site course, we will come to you and hold the course in your office. The price is determined by our price model and is based on the number of course days, number of participants and any travel and lodging.

Read more about out price modell and term of sales here.

Related Courses
Groovy3Beginner Show
Grails Web Apps5Beginner Show
JUnit Tests1 IntermediateShow