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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Testing legacy apps with Spock

1,940
views

Published 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

Published in: Technology

0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,940
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
6
Embeds 0
No embeds

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!