- We design and build extraordinary applications for companies looking to make the next great idea a reality.
- learn more
Agile Development and Testing: Unit or Montecarlo?
I've had a running debate with my colleague John McCaffrey on the question of testing. He is a big fan of unit testing and testing in general that examines the smallest possible units to be tested, then assembles them in every larger integration tests. The idea is that if you get the small stuff right, then the larger stuff has a greater chance of being right too.
Come to think of it, I'm a big fan of this approach too. But there are some times that this sort of strict constructionism is insufficient. There are a few instances that a comprehensive system test is necessary. Some instances that come to mind are:
- Systems where the correctness of third party hardware or software and it's interaction with our system need to be verified. For example, network hardware and operating system interaction with video conferencing software.
- Complex algorithms and logic whose correctness is difficult to prove mathematically. For example, if your software application allows complex logic to be written by the end user, essentially amounting to the end user writing programs themselves. The Four Color Problem is an excellent example of the sort of algorithm whose correctness is difficult to test and required far more effort than the development of a correct algorithm.
- High value systems where an error or an oversight in a unit or integration test can lead to damaging consequences. Security of online systems is an excellent example of this; perhaps the most tested area of applications, we still regularly hear of compromised applications.
There are a number of ways to tackle these types of testing challenges, but many of the approaches resemble an empirical, almost experimental tack: treat the system as a black box and record and measure inputs and outputs.
Security and Fuzzing
One extreme approach to security testing, known as "fuzzing", treats the target system as a black box and tries to subvert it by feeding it garbage, e.g. in the case of a web application, pass it crazy query string, do a POST with a large amount to binary data instead of a simple GET, send it bogus cookies, etc. Now do this a massive number of times with randomly generated attacks. See what breaks. (See here for a list of web fuzzing tools.) The nice thing about fuzzing from a agile development perspective is that is can be automated and, as long as it is black box, doesn't have to be constantly updated the way interface level tests (i.e. Selenium) do.
The Myth of Code Coverage
If you do Unit Testing, you want to measure how good of a job you are doing. Thus we make use of code coverage tools to see what percentage of line and branch coverage we have. Where code "coverage" is somewhat misleading is that it doesn't take into account state, i.e. if you are testing a class and it has instance variables, say two characters that can contain 'a' thru 'z', then you have 26 * 26 = 676 different possible states. If you add a few more instance variables with larger ranges, some lists of related objects, etc., etc., you can get into some pretty serious state.
How complex can this get? Consider the case where our class represents a Turing machine, with a tape instance variable, and a finite state instruction set. Testing that class is the same as testing any arbitrary program -- very very very hard.
You might scoff and say that your code doesn't implement anything a silly as a Turing machine, but how many software programs contain an implicit or explicit language -- configurable logic for survey applications, extensible behavior for editors, formulas and scripts in spreadsheets -- that represent the same sort of complexity?
So, you should still do your Unit Testing, but when your software starts to resemble a programming environment, include large system regression and random walks through the application functionality.
Topics: Agile Development, Testing
Leave a comment
About Pathfinder
Recent
- Walk-Through Test Coverage
- Where minimalism fails: The problem with Apple’s less-is-more approach
- jQuery goodness with ASP .NET
- Design Thinking
- Bullseye Diagram
- Roles Testing For Security
- Blackbird takes the pain out of JavaScript logging
- Making GWT JSON not Quite so Painful
- IDEA - preconference workshop 06 Oct 08
- HTML5, Ajax history management, and The Ajax Experience 2008 Boston
Archives
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006

