Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced Testing Techniques on Force.com - Clou...

Advanced Testing Techniques on Force.com - Cloudstock London 2012

These are the slides to accompany my presentation on Advanced Testing Techniques on Force.com given at the Cloudstock London 2012 event. The presentation gives a brief overview of mocking, stuibbing testing and how using these ideas can improve our Force.com applications.

Avatar for Paul Battisson

Paul Battisson

May 23, 2012
Tweet

Other Decks in Programming

Transcript

  1. Introduction • Paul Battisson (@pbattisson) • Xactium • What? ◦

    Mocking ◦ Stubbing ◦ Patterns ◦ Next steps • Why? ◦ Improve testability ◦ Improve flexibility ◦ Work faster
  2. What's Wrong With Force.com Testing? • "Slow" to write •

    "Slow" to run • Brittle • High data dependence • Tests written badly • Coded badly - highly coupled • Lots of testing of DML
  3. More Interfaces • Code against interfaces • Plug sockets (@simongoodyear)

    • Immediate improvement in flexibility and testability
  4. Mock Objects • Implement the same interface • Used in

    place for a test • Assertions on how we expect the object to be called • Can contain stubs for flow • Allow us to test our object's interaction with its neighbours
  5. Stubbing • Simulate real behaviour to get a test to

    pass • Implement in a mock object or using isRunningTest()*
  6. Less Test Data Setup Insert a Record Required Fields? Validation

    Rules? Before Trigger After Trigger Instantiate a Mock