Recommended Practice: Test Driven Development

We extensively use unit testing here at ValEx.

A lot of the errors we see seem to be related to 'common-sense' failing - for instance, sending back date information in packets that can't be valid.

To prevent these types of errors, we suggest writing out unit tests ahead of time utilising one of the unit test frameworks in your language.

We recommend that your unit tests:

  • Validate sample packets generated from your system against an XSD
  • Deliberately try to generate wrong information (ie, dates), and expect your system to gracefully handle the error
  • Explicitly cover rendering (data to xml), parsing (xml to data), processing (data to actions), and generation (actions to data), connecting (xml -> outgoing soap request), and serving (incoming soap request -> xml)

Examples include:

  • Test that you cannot send a workflow packet containing inspection date details that are before the date of the job
  • Test that if you don't have certain information (ie, dates, comments), the node is removed from the tree, rather than simply blank
  • Test that you can't send certain information (ie, valuation response) before you've sent other data (workflow for valuation accepted)

 

Using some unit testing frameworks, it's very easy to generate Agile Documentation. Below is a some of our agile documentation, demonstrating just some of the tests we run against our lixi & webservices code. Implementing similar tests is definitely encouraged.

WorkFlowParsing

  • Delay status correctly parses
  • Assigned status correctly parses
  • Accepted status correctly parses
  • Inspected status correctly parses
  • Corrupt work flow delay causes failure
  • Corrupt work flow assigned causes failure
  • Corrupt work flow inspection causes failure
  • Stupid historical dates cause failure
  • Invalid time fails
  • Missing date of inspection fails
  • Inspection date is correctly parsed
  • Invalid inspection date fails
  • Lixi date objects should not default to today
  • Lixi time objects should behave correctly

WorkFlowRendering

  • Should correctly render workflow delay information
  • Should fail to render invalid delay information
  • Should correctly render workflow appointment information
  • Should fail to render invalid appointment information
  • Should correctly render workflow inspection information
  • Should fail to render invalid inspection information

WorkFlowProcessing

  • Inbound workflow delay should add delay
  • Inbound workflow action should set appointment made
  • Inbound workflow action should set inspection date

ResponseShortFormParsing

  • Should parse response
  • Should raise value exception when given an unknown suburb in comparison sales data
  • Should find attached pdf report in response
  • Should find attached images in response
  • Should raise xml exceptions when given invalid xml

ResponseRendering

  • A valuation response containing a residential short form dwelling report should render correctly
  • Sales evidence comparison comments should map to lixi