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

Like this? Share it with your network

Share

Testing legacy apps with Spock

on

  • 2,314 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,314
Views on SlideShare
2,313
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 Presentation Transcript

  • 1. MarcinGryszko
    @mgryszko
    TestinglegacyappswithSpock
  • 2. Mymotivation
    Retrofit a legacyapp (Java + Hibernate+ Spring) with automated tests
    WhynotwithGroovy?
    Butwhattool?
  • 3. Theansweris...
    Spock!
  • 4. 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
  • 5. 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?
  • 6. Featuremethod blocks
    4 test phases in blocks
    Setup => setup: / given:/ where:
    Execute => when: / expect:
    Verify => then: / expect:
    Teardown => cleanup:
    and:
  • 7. Data-driventests
    Withwhere block
    where:
    bankName << ['BPH', 'BOS', 'HSBC']
  • 8. Modules
    Spock Spring
    • Annotatespecwith@ContextConfiguration
    • 9. Use Spring DI (@Autowired, @Resource)
    • 10. AlmostallTestContextannotationswork
    SpockUnitils
    • Unitils – library of test helpers (mocking, persistence, Spring, …)
    • 11. Wrapper for DbUnit
    • 12. Spring integration – was useful whenSpring TestContextwasnotyetimplemented
    • 13. 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
  • 14. Enoughtalk, let’scode!
    And implement a specification
    https://github.com/mgryszko/blog-spock-spring-unitils
  • 15. 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/
  • 16. THANK YOU!