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

Like this? Share it with your network

Share

Testing legacy apps with Spock

  • 2,364 views
Uploaded on

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,364
On Slideshare
2,363
From Embeds
1
Number of Embeds
1

Actions

Shares
Downloads
19
Comments
0
Likes
4

Embeds 1

https://www.linkedin.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

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!