Spock Testing

How to write test program 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

Extensions

  • Annotations
  • Ignore annotations
  • Requires
  • Stepwise
  • Timeout
  • AutoCleanup
  • Title
Facts
NameSpock Testing
Duration1 Days
LevelIntermediate
AudienceJava programmers
PrerequisitesPractical knowledge in Javav programming
Tools
  • Groovy
  • Spock
  • JetBrains Intellij IDEA
  • Java JDK, version 8+
Price11 000 kr + moms 11000
Course Dates
DatePlace
Loading course dates...
Same-Company Discout

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

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
CourseDaysLevel
Groovy3Beginner Show
Grails Web Apps5Beginner Show
JUnit Tests1Intermediate Show