Testing for fun and profit
March, 11th 2010
Are you still testing manually?
● Are you testing the applications you write?
● You are already testing, but in an inefficient
● Manual testing is boring and inefficient!
● Automated testing makes development more
effective and more fun!
Create a new Plone content type
Create Plone Site
Test Adding Manually
Test View Manually
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!
Development Process Improvement
● Automate the entire process
● Write tests that can tell you what exactly went
● Fixing lots of small pieces of code mean lots of
● Prove that your code does what it is supposed
● Make development more fun!
What Do We Want To Test?
● Factory Type Information
Run your tests
Create Content Type
Test Factory Type Information
Why Testing Matters
● Testing reduces defects as measured by
● 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
XP/Scrum and Functional Testing
● Testing started as part of XP
● Acceptance tests can map directly to your software
● Write testable specifications
● Write code that complies with the specification and
● Use the testable specification to prove that your
application is doing what it is supposed to do
Telling User Stories with Doctests
As a logged-in user, I can add a new Task to the
Testing one unit at a time
● Usually you have to set up some components
in order to test a Unit
● But how?
Mock And Fake Objects
● Unittest code that has external dependencies
● Plone components
● External databases
● Network connections
● Depends on external components
Mock Testing Example
Test Driven Development
● Write a testable specification
● Write integration tests
● Write Unit Tests
● Write code that complies with the specification
● Use the testable specification and unit tests to
More Testing Topics
● Code Coverage
● Continuous Integration
● IDE Integration