SPOCK:
BOLDLY GO
WHERE NO TEST
HAS GONE
BEFORE
ANDRES ALMIRAY
CANOO ENGINEERING A.G.

@AALMIRAY
ABOUT THE SPEAKER
Java developer since the beginning

True believer in open source
Groovy committer since 2007
Project lead of the Griffon framework
Currently working for
WHAT IS SPOCK?
Where, Who, How?
■ http://spockframework.org
■ Peter Niederwiser
@pniederw
■ Groovy based Testing
Language
■ Byte code manipulation at
compile time
■ Inspired by
JUnit, Rspec, jMock, Moc
kito, Groovy, Scala and

Why?
■ Expressive testing
language
■ Easy to learn
■ Usable from unit to end-toend level
■ Leverages Groovy
language features
■ Runs with JUnit:
compatible with IDEs, build
tools & CI
■ Extensible for specialized
testing scenarios

3
FIRST CUT

4
INTRODUCING A BUG

5
A WILD ERROR APPEARS!

6
FEATURE LIST (1)
Blocks
■ given:
■ when:
■ then:
■ expect:
■ where:
■ and:
■ setup:
■ cleanup:

preconditions, data fixtures, etc.
actions that trigger some outcome
makes assertions about outcome
short alternative to when & then
applies varied inputs
sub-divides other blocks
alias for given
post-conditions, housekeeping, etc.

7
FEATURE LIST (2)
Lifecycle
■ setup
■ cleanup
■ setupSpec
■ cleanupSpec

Data Driven
■ List based variables
■ Table based variables
■ @Unroll
■ @Shared

8
UNROLLING

9
UNROLLING AS SEEN BY AN IDE

10
INTERACTIONS (MOCKS)

11
BUT WAIT, THERE’S MORE!
■ http://docs.spockframework.org/en/latest
■ Spock is extensible via plugins
■ Functional web testing with GEB
■ Plugins exist for Grails and Griffon
■ Next release will be 1.0.0

12
THANK
YOU!
@AALMIRAY

HTTP://PEOPLE.CANOO.COM/SHARE/

JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before

  • 1.
    SPOCK: BOLDLY GO WHERE NOTEST HAS GONE BEFORE ANDRES ALMIRAY CANOO ENGINEERING A.G. @AALMIRAY
  • 2.
    ABOUT THE SPEAKER Javadeveloper since the beginning True believer in open source Groovy committer since 2007 Project lead of the Griffon framework Currently working for
  • 3.
    WHAT IS SPOCK? Where,Who, How? ■ http://spockframework.org ■ Peter Niederwiser @pniederw ■ Groovy based Testing Language ■ Byte code manipulation at compile time ■ Inspired by JUnit, Rspec, jMock, Moc kito, Groovy, Scala and Why? ■ Expressive testing language ■ Easy to learn ■ Usable from unit to end-toend level ■ Leverages Groovy language features ■ Runs with JUnit: compatible with IDEs, build tools & CI ■ Extensible for specialized testing scenarios 3
  • 4.
  • 5.
  • 6.
    A WILD ERRORAPPEARS! 6
  • 7.
    FEATURE LIST (1) Blocks ■given: ■ when: ■ then: ■ expect: ■ where: ■ and: ■ setup: ■ cleanup: preconditions, data fixtures, etc. actions that trigger some outcome makes assertions about outcome short alternative to when & then applies varied inputs sub-divides other blocks alias for given post-conditions, housekeeping, etc. 7
  • 8.
    FEATURE LIST (2) Lifecycle ■setup ■ cleanup ■ setupSpec ■ cleanupSpec Data Driven ■ List based variables ■ Table based variables ■ @Unroll ■ @Shared 8
  • 9.
  • 10.
    UNROLLING AS SEENBY AN IDE 10
  • 11.
  • 12.
    BUT WAIT, THERE’SMORE! ■ http://docs.spockframework.org/en/latest ■ Spock is extensible via plugins ■ Functional web testing with GEB ■ Plugins exist for Grails and Griffon ■ Next release will be 1.0.0 12
  • 13.