Successfully reported this slideshow.
Your SlideShare is downloading. ×

Test Motherfucker...Test

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Rubyslava debugging with_pry
Rubyslava debugging with_pry
Loading in …3
×

Check these out next

1 of 28 Ad

More Related Content

Similar to Test Motherfucker...Test (20)

Advertisement

Recently uploaded (20)

Advertisement

Test Motherfucker...Test

  1. 1. First things first • Mario García • Freelance • Happily working with Grails every day • Blamed for a felony I didn’t commit I ran away to Ireland...still there!! marioggar desmontandojava.blogspot.com mariogarcia
  2. 2. What is this about? because we don’t need to test...do we?
  3. 3. What is this about? WE ARE NOT PERFECT
  4. 4. When do we realize? WTF!!
  5. 5. Why I test? • Do they make me flawless? Nop, In fact they remind me every day how bad I am • Do they avoid bugs?me to detect them Nop, but they help before is too late
  6. 6. Sample Code • https://github.com/mariogarcia/maroulette
  7. 7. Integration Tests Why first???
  8. 8. Why first? • ... because you do all your important stuff in services, Don’t you MTF?
  9. 9. What to test? • External systems integration: • Database • Web-services / Rest • Queue system • ...
  10. 10. Weapons • Grails “inbuilt” integration tests • 2.0.x > * Interactive mode & Guard Plugin • Spock • Fixtures • Build Test Data
  11. 11. Grails Integration Tests • By default • JUnit Based • The application is “UP AND RUNNING” • Use the interactive mode to save time
  12. 12. Plugins • Spock • More natural way of writing tests • Parameter tables ROCKS!!! • Helps you to document!!!
  13. 13. Plugins • Fixtures Plugin • We can create common testing datasets • Build Test Data Plugin • Sometimes we don’t care about field values • Just give me a valid persisted instance!!
  14. 14. Plugins • Spock: http://grails.org/plugin/spock • Fixtures: http://grails.org/plugin/spock • Build Test Data: http://grails.org/plugin/spock • Guard: http://grails.org/plugin/guard
  15. 15. Grails Integration Tests
  16. 16. Unit Testing The easiest one?
  17. 17. Usual Suspects • Controllers • Taglibs • UrlMappings • Filters • Other silly things...
  18. 18. Typical Case • Testing a controller • What the output view is gonna be if • everything went ok ? • everything went wrong ? • Should the user see any message? • Etc...
  19. 19. Weapons • Grails Mocking • Don’t test controllers with real services • Use Mixins instead to simulate them • Learn to create expectations
  20. 20. Weapons • Spock Tables to the rescue!!! • Natural way of doing use cases in your controllers
  21. 21. Grails Unit Testing
  22. 22. Functional Testing Is it working as the user expected? Game Over!
  23. 23. Functional testing • Plugins • Functional Testing • http://www.grails.org/plugin/functional-test • Geb • http://www.grails.org/plugin/geb
  24. 24. Functional Testing
  25. 25. Please, don’t hate JS it’s cute, isn’t it?
  26. 26. Testing JS • http://grails.org/plugin/jasmine • http://grails.org/plugin/angularjs-resources • casperjs • https://github.com/ulrich/grails-casper-plugin
  27. 27. Q&A Ask now or be quiet forever!!!

×