Testing legacy apps with Spock
Upcoming SlideShare
Loading in...5
×
 

Testing legacy apps with Spock

on

  • 2,284 views

Presentation for the 1. meeting of Madrid Groovy User Group

Presentation for the 1. meeting of Madrid Groovy User Group

Twitter:
http://twitter.com/madridgug
Google group:
https://groups.google.com/group/madrid-gug

Statistics

Views

Total Views
2,284
Views on SlideShare
2,283
Embed Views
1

Actions

Likes
4
Downloads
17
Comments
0

1 Embed 1

https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Testing legacy apps with Spock Testing legacy apps with Spock Presentation Transcript

  • MarcinGryszko
    @mgryszko
    TestinglegacyappswithSpock
  • Mymotivation
    Retrofit a legacyapp (Java + Hibernate+ Spring) with automated tests
    WhynotwithGroovy?
    Butwhattool?
  • Theansweris...
    Spock!
  • WhyGroovy and Spockfor a Java developer?
    Groovy
    powerfulsyntax
    codeless and do more
    Spock
    BDDstyletesting
    describe featuresthroughexecutablespecifications
    documentation and examples of legacycode
    Integrateswith Spring & DbUnit
    RunswithJUnit 4 => Maven, CI
  • Extendspock.lang.Specification
    classBankDaoSpecextendsSpecification
    Define a feature (test) method
    def “finds a bank by id"() {
    // blocks for 4 test phases
    setup:
    when:
    then:
    }
    HOW DO I TEST?
  • Featuremethod blocks
    4 test phases in blocks
    Setup => setup: / given:/ where:
    Execute => when: / expect:
    Verify => then: / expect:
    Teardown => cleanup:
    and:
  • Data-driventests
    Withwhere block
    where:
    bankName << ['BPH', 'BOS', 'HSBC']
  • Modules
    Spock Spring
    • Annotatespecwith@ContextConfiguration
    • Use Spring DI (@Autowired, @Resource)
    • AlmostallTestContextannotationswork
    SpockUnitils
    • Unitils – library of test helpers (mocking, persistence, Spring, …)
    • Wrapper for DbUnit
    • Spring integration – was useful whenSpring TestContextwasnotyetimplemented
    • Notactivelydeveloped
  • More integrations
    SpockGrails & Grailsplugin
    http://www.grails.org/plugin/spock
    Gebintegration (GebSpec)
    http://geb.codehaus.org/manual/latest/integrations.html#spock
    Guice, Maven, Tapestry
  • Enoughtalk, let’scode!
    And implement a specification
    https://github.com/mgryszko/blog-spock-spring-unitils
  • Resources
    Spock
    http://code.google.com/p/spock/
    GrooviertestingwithSpock
    http://www.slideshare.net/rfletcher/groovier-testing-with-spock
    Testing A Legacy Java Application With Groovy, Spock, Spring Test And Unitils
    http://mgryszko.wordpress.com/2011/02/15/testing-a-legacy-java-application-with-groovy-spock-spring-test-and-unitils/
    Unitils
    http://www.unitils.org/
  • THANK YOU!