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

A Gentle Introduction to Unit Testing with MXUnit

A Gentle Introduction to Unit Testing with MXUnit

Presented to the Johns Hopkins Adobe User Group, April, 2010.

Brian Klaas

April 27, 2010
Tweet

More Decks by Brian Klaas

Other Decks in Technology

Transcript

  1. ) (

  2. ) (

  3. ( ) Unit vs. Integration Testing ⊛ Small units vs.

    sequences ⊛ MXUnit vs. Selenium
  4. ) (

  5. ( ) ⊛ Write test code that fails ⊛ Make

    the test work ⊛ Refactor/refine
  6. ( ) The Basics ⊛ Write a test shell ⊛

    Write the code to make it work ⊛ Verify that it works ⊛ Repeat
  7. ( ) The Reality ⊛ Write the code ⊛ Write

    the test ⊛ Make sure it works ⊛ This is not TDD!
  8. ( ) Assertions ⊛ assertEquals(expected,result) ⊛ assertNotSame(expected,result) ⊛ assertSame(expected,result) ⊛

    assertFalse(someVariable or function result) ⊛ assertTrue(someVariable or function result) ⊛ assertXPath(String xpath, any data, [String text], [String message]) ⊛ assertIsTypeOf(component obj, String type) ⊛ assertIsXMLDoc(any xml) ⊛ assertIsArray(any obj1) ⊛ assertIsDefined(any obj1)
  9. ( ) How to Test ⊛ Test one thing per

    test ⊛ Write tests for every possible scenario ⊛ Test for success and failure
  10. ( ) How to Test ⊛ Test in isolation ⊛

    setup()/teardown() ⊛ Mocking dependencies ⊛ injectMethod ⊛ injectProperty
  11. ( ) Debugging ⊛ <cfdump>/<cfoutput> ⊛ request.debug( ) method in

    tests ⊛ “Open test case results in browser”