Monday, September 29, 2008

Snapshot in UI Testing

If you have experience in JUnit or other testing tools, you probably know the importance of setup and teardown methods. These two methods help build a testing environment. However, when it comes to UI testing, it is not the case. UI testing means taking a long time, boring, and random exceptions. What's more, every time an error occurs, which might be caused either by a typo or by the tested codes, the only solution is to start over again from the very beginning. This is boring!

If we could take a snapshot at certain points (which are called save points), we could easily get started from those points. It should be time efficient. It certainly save a lot of time otherwise wasted in setting up the environment again. What's more, you can benefit from reproducing some random errors. If a snapshot were taken just before it occurs, the error would probably show up again, which also helps reduce the number of bugs.

It is not too hard to implement such a system. There are various ways though. It can be implemented as a functionality of the testing tools, or it could be bounded with the help of underlying systems. One good candidate is the virtual machine. Most VMMs, including open source ones, have a similar function. Taking snapshot takes seconds to minutes, depending on the implementations of VMM and the size of the virtual machine. We could take multiple snapshots, and rollback to a certain one, and even make branches. Although making use of VMM might seem easier, it is harder, but necessary, to integrate the snapshot into the testing tools. Taking snapshot should be as simple as setting breakpoints in debug.