Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Curtis "Ovid" Poe
http://allaroundtheworld.fr/
http://blogs.perl.org/users/ovid/
http://www.slideshare.net/Ovid/testclassm...
info@allaroundtheworld.fr
• 
• 
• 
• 

OO tests for OO code
Nice performance boost
Easy to organize tests
Already use Moose

info@allaroundtheworld....
info@allaroundtheworld.fr
1.  Getting started with Test::Class
2.  Inheriting Test::Class tests
3.  Making your testing life easier
4.  Using test c...
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
Solution?
✘
✘
✓

Instantiate the object correctly?

info@allaroundtheworld.fr
• 
• 
• 
• 

We've written two classes
We've written two test classes
We've seen test inheritance
… but it broke our test!...
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
•  It works
•  But we constructed our object twice
•  Wash/rinse/repeat for every test method?

info@allaroundtheworld.fr
Method

Phase
Before each test class
Before each test method
After each test method
After each test class

info@allaroundt...
• 
• 
• 
• 
• 

Connect to a database (often in startup)
Set up fixtures/transactions (setup)
Clean fixtures/rollbacks (te...
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
• 
• 
• 
• 
• 
• 
• 

Only run API tests
Only run unit tests
Run correct code coverage
Run Jenkins tests
Run DB tests
Crea...
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
• 
• 
• 
• 

Fine-grained control
xUnit-style testing
Full Moose integration
Reporting

info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
?
info@allaroundtheworld.fr
Upcoming SlideShare
Loading in …5
×

Test::Class::Moose

Test::Class::Moose combines Test::Class, Moose and Test::Most to take test suites to the next level. It gives you unparalleled levels of control and information for you test suite.

  • Login to see the comments

Test::Class::Moose

  1. 1. Curtis "Ovid" Poe http://allaroundtheworld.fr/ http://blogs.perl.org/users/ovid/ http://www.slideshare.net/Ovid/testclassmoose info@allaroundtheworld.fr
  2. 2. info@allaroundtheworld.fr
  3. 3. •  •  •  •  OO tests for OO code Nice performance boost Easy to organize tests Already use Moose info@allaroundtheworld.fr
  4. 4. info@allaroundtheworld.fr
  5. 5. 1.  Getting started with Test::Class 2.  Inheriting Test::Class tests 3.  Making your testing life easier 4.  Using test control methods 5.  Test::Class tricks On www.modernperlbooks.com info@allaroundtheworld.fr
  6. 6. info@allaroundtheworld.fr
  7. 7. info@allaroundtheworld.fr
  8. 8. info@allaroundtheworld.fr
  9. 9. info@allaroundtheworld.fr
  10. 10. info@allaroundtheworld.fr
  11. 11. info@allaroundtheworld.fr
  12. 12. info@allaroundtheworld.fr
  13. 13. info@allaroundtheworld.fr
  14. 14. info@allaroundtheworld.fr
  15. 15. info@allaroundtheworld.fr
  16. 16. info@allaroundtheworld.fr
  17. 17. info@allaroundtheworld.fr
  18. 18. info@allaroundtheworld.fr
  19. 19. info@allaroundtheworld.fr
  20. 20. info@allaroundtheworld.fr
  21. 21. info@allaroundtheworld.fr
  22. 22. info@allaroundtheworld.fr
  23. 23. info@allaroundtheworld.fr
  24. 24. Solution? ✘ ✘ ✓ Instantiate the object correctly? info@allaroundtheworld.fr
  25. 25. •  •  •  •  We've written two classes We've written two test classes We've seen test inheritance … but it broke our test! info@allaroundtheworld.fr
  26. 26. info@allaroundtheworld.fr
  27. 27. info@allaroundtheworld.fr
  28. 28. info@allaroundtheworld.fr
  29. 29. •  It works •  But we constructed our object twice •  Wash/rinse/repeat for every test method? info@allaroundtheworld.fr
  30. 30. Method Phase Before each test class Before each test method After each test method After each test class info@allaroundtheworld.fr
  31. 31. •  •  •  •  •  Connect to a database (often in startup) Set up fixtures/transactions (setup) Clean fixtures/rollbacks (teardown) Disconnect from database (shutdown) And more … info@allaroundtheworld.fr
  32. 32. info@allaroundtheworld.fr
  33. 33. info@allaroundtheworld.fr
  34. 34. info@allaroundtheworld.fr
  35. 35. info@allaroundtheworld.fr
  36. 36. info@allaroundtheworld.fr
  37. 37. info@allaroundtheworld.fr
  38. 38. info@allaroundtheworld.fr
  39. 39. info@allaroundtheworld.fr
  40. 40. info@allaroundtheworld.fr
  41. 41. info@allaroundtheworld.fr
  42. 42. info@allaroundtheworld.fr
  43. 43. •  •  •  •  •  •  •  Only run API tests Only run unit tests Run correct code coverage Run Jenkins tests Run DB tests Create fixtures only if the test needs it Skip network tests if the network is down info@allaroundtheworld.fr
  44. 44. info@allaroundtheworld.fr
  45. 45. info@allaroundtheworld.fr
  46. 46. info@allaroundtheworld.fr
  47. 47. info@allaroundtheworld.fr
  48. 48. info@allaroundtheworld.fr
  49. 49. info@allaroundtheworld.fr
  50. 50. info@allaroundtheworld.fr
  51. 51. info@allaroundtheworld.fr
  52. 52. •  •  •  •  Fine-grained control xUnit-style testing Full Moose integration Reporting info@allaroundtheworld.fr
  53. 53. info@allaroundtheworld.fr
  54. 54. info@allaroundtheworld.fr
  55. 55. info@allaroundtheworld.fr
  56. 56. ? info@allaroundtheworld.fr

×