+ All Categories
Home > Technology > JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before

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

Date post: 17-Jan-2015
Category:
Upload: jazoon13
View: 209 times
Download: 2 times
Share this document with a friend
Description:
 
Popular Tags:
13
SPOCK: BOLDLY GO WHERE NO TEST HAS GONE BEFORE ANDRES ALMIRAY CANOO ENGINEERING A.G. @AALMIRAY
Transcript
Page 1: JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before

SPOCK:BOLDLY GO WHERE NO TEST HAS GONE BEFOREANDRES ALMIRAYCANOO ENGINEERING A.G.

@AALMIRAY

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

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

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

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, Mockito, Groovy, Scala and Vulcans

3

Why?

■ Expressive testing language

■ Easy to learn

■ Usable from unit to end-to-end level

■ Leverages Groovy language features

■ Runs with JUnit: compatible with IDEs, build tools & CI

■ Extensible for specialized testing scenarios

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

4

FIRST CUT

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

5

INTRODUCING A BUG

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

6

A WILD ERROR APPEARS!

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

FEATURE LIST (1)

Blocks

■ given: preconditions, data fixtures, etc.

■ when: actions that trigger some outcome

■ then: makes assertions about outcome

■ expect: short alternative to when & then

■ where: applies varied inputs

■ and: sub-divides other blocks

■ setup: alias for given

■ cleanup: post-conditions, housekeeping, etc.

7

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

FEATURE LIST (2)

Lifecycle

■ setup

■ cleanup

■ setupSpec

■ cleanupSpec

8

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

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

9

UNROLLING

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

UNROLLING AS SEEN BY AN IDE

10

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

11

INTERACTIONS (MOCKS)

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

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

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

THANK YOU!

@AALMIRAY

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


Recommended