UPC Plone Testing Talk

900 views
784 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
900
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

UPC Plone Testing Talk

  1. 1. Testing for fun and profit March, 11th 2010 Timo Stollenwerk
  2. 2. Are you still testing manually? ● Are you testing the applications you write? ● You are already testing, but in an inefficient way! ● Manual testing is boring and inefficient! ● Automated testing makes development more effective and more fun!
  3. 3. Create a new Plone content type
  4. 4. Start Zope
  5. 5. Create Plone Site
  6. 6. Install Product
  7. 7. Test Adding Manually
  8. 8. Error!
  9. 9. Test View Manually
  10. 10. What sucks about this process? ● You have to create/start/install/test your product over and over again ● You have to write the entire code before you can test it ● You end up with a lot of errors and you don't really know what is causing it ● Manual testing is slow and error-prone! ● Repetitive tasks are boring!
  11. 11. Development Process Improvement ● Automate the entire process ● Write tests that can tell you what exactly went wrong ● Fixing lots of small pieces of code mean lots of small successes ● Prove that your code does what it is supposed to do ● Make development more fun!
  12. 12. What Do We Want To Test? ● Schema ● Factory Type Information ● Factory ● Adding ● View ● ...
  13. 13. Create Schema
  14. 14. Test Schema
  15. 15. Run your tests
  16. 16. Create Content Type
  17. 17. Test Factory Type Information
  18. 18. Test Factory
  19. 19. Error!
  20. 20. Test Adding
  21. 21. Test View
  22. 22. Why Testing Matters ● Testing reduces defects as measured by reported bugs ● Finding bugs early makes them cheaper to fix ● Tests passing is proof that you delivered what you were contracted to produce ● Refactor with confidence ● Lot of small steps means lot of small successes
  23. 23. Testing Pyramid
  24. 24. Functional Testing ● Blackbox testing ● Automated acceptance testing
  25. 25. XP/Scrum and Functional Testing ● Testing started as part of XP ● Acceptance tests can map directly to your software requirements ● XP/Scrum: ● Write testable specifications ● Write code that complies with the specification and tests ● Use the testable specification to prove that your application is doing what it is supposed to do
  26. 26. Telling User Stories with Doctests As a logged-in user, I can add a new Task to the website.
  27. 27. Doctest Example
  28. 28. Unit Tests in Plone
  29. 29. Unit Testing CODE: def is_palindrome(input_str): pass TEST: def test_palindromic_word(): input = "noon" assert is_palindrome(input) == True
  30. 30. Testing one unit at a time ● Usually you have to set up some components in order to test a Unit ● But how?
  31. 31. Mock And Fake Objects ● Unittest code that has external dependencies ● Plone components ● External databases ● Network connections ● Depends on external components
  32. 32. Mock Testing Example
  33. 33. Test Driven Development ● Write a testable specification ● Write integration tests ● Write Unit Tests ● Write code that complies with the specification and tests ● Use the testable specification and unit tests to help debug/refactor
  34. 34. More Testing Topics ● Code Coverage ● Twill ● Selenium ● zope.testrecorder ● Continuous Integration ● IDE Integration
  35. 35. Code Resources ● Code for this talk upc.testingtutorial ● https://devel.upcnet.es/svn/upcnet/upc.testingtutorial/ ● UPC Deploymentmanager ● https://devel.upcnet.es/svn/upcnet/upc.deploymentmana ● Recent Activity Portlet ● http://pypi.python.org/pypi/collective.portlet.recentactivit ● plone.app.discussion ● http://pypi.python.org/pypi/plone.app.discussion
  36. 36. Testing Resources ● Plone Testing Tutorial ● http://plone.org/documentation/kb/testing ● Plone 3 / Archetypes ● PPD / Optilux ● Plone 4 / Dexterity Dev Manual ● http://plone.org/products/dexterity/documentation/manu ● Example Package: http://svn.plone.org/svn/collective/example.conferen ce/
  37. 37. Books about Testing ● Kent Beck: Test Driven Development ● http://www.amazon.com/Test-Driven-Development-Kent ● Python Testing: Beginner's Guide ● http://www.packtpub.com/python-testing-beginners-guid ● Tarek Ziadé: Expert Python Programming ● http://www.amazon.com/Expert-Python- Programming-practices- distributing/dp/184719494X/ref=sr_1_1? ie=UTF8&s=books&qid=1268299804&sr=1-1-spell
  38. 38. The End

×