Your SlideShare is downloading. ×
0
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
Testing legacy apps with Spock
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

2,043

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

×