Getting Started with Geb and Spock

Spock

  • Testing and Specification Framework for Java and Groovy Apps
  • https://code.google.com/archive/p/spock/

Why Spock

  • Simple
  • Supports Data-Driven Tests
  • Great Mocking Supports
  • Integrates with Tooling

Getting Started

  • Extends Specification
  • Fixture Methods
    • setup
    • cleanup
    • setupSpec
    • cleanupSpec

Geb

Functional Testing

Functional Tests are important aspect of Web Application Development. Some major bugs cannot be identified by Unit Tests because when it comes in Web Application Development there are lots of components working together and only way to fully test an application is via writing robust functional tests to mimic actual usual behavior and see how the code handles those conditions.

Geb

  • Groovy layer built on top of Selenium WebDriver
    • Test written in Groovy
    • Geb works with Spock
  • Content DSL
  • jQuery Style Content Inspection Model

Page Object Pattern

  • Geb encourages page object approach
  • Define Page Objects that represents the key interaction element of a page.
  • By convention, Pages are placed in separate sub-package.
  • Test Specification

[Slides]