MVC for Testing?

by Kingston Duffie (KingstonD) on 10-30-2008 03:44 PM

Model-view-controller (MVC) is a successful architectural pattern for modern software–especially for native GUI and Web applications. The basic idea is to cleanly separate the code into three distinct pieces:

  • Model: the state information
  • View: the user interface (UI)
  • Controller: the business logic

Some people also talk about three-tier architectures–which are very similar–with presentation, business logic, and data tiers.

This is great to know if you are designing software. But what about testing?

Testing traditionally involves some manual testing followed by some work to automate that testing. In the world of system testing (at least until Fanfare came along), you typically use one set of tools for manual testing (e.g., a virtual terminal, Web browser, SNMP browser, traffic generator GUI, etc.) and a different set of tools for automated testing (e.g., Tcl scripts and specialized Tcl libraries). In the automated world, no UI exists, so these GUI-oriented tools (like terminals and browsers) aren’t appropriate in a “lights-out” automated testing system.

If you step back and think about it, however, these GUI tools are the “V” in “MVC.” So, why can’t I keep the same M and C during automated testing, and just discard the V? Well, actually you can. In fact, that is exactly what iTest does!

The tools that you use to do manual testing inside iTest are built on top of an MVC model. So when you want to automate a test, you can simply throw out the V. And when you are debugging an automated test in the iTest GUI, you can easily add the V back in, so that you can see the UI windows for all the tools being used as the test executes.

With this said, if you are a believer in MVC or three-tier software architectures, you may find that the iTest model for testing is right up the same alley.

Kingston Duffie is the founder and CTO of Fanfare.
Learn more about Kingston >>