Test::Class::Moose

4,304
-1

Published on

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.

Published in: Technology, Business
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,304
On Slideshare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • No need to add empty control methods
  • No need to add empty control methods
  • No need to add empty control methods
  • We've skipped some usual Moose boilerplate (namespace::autoclean and make_immutable)
  • Methods beginning with test_ are test methods.Two objects to every method
  • This works, but we constructed our object more than once. We don't want duplicated code.
  • 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

    ×