This afternoon, Niall Ross is doing a talk on Extreme UI Testing. Heh: from 1999:
One of the great things about the web is that it's trained our users to not be so picky. They're now accustomed to seeing UIs that look like garbage and change without notice"
Niall is probably right in saying that Ajax (and Apollo, and Silverlight) are undermining this assumption. For UI testing, there are options: SilverMark's Test Mentor, Dave Buck's VWUnit. James Foster has extended WinRunner as well. Niall says that these tools are good for retrofitting an existing system. They don't really support "Test First" (i.e., you can't click an unpainted widget).
An approach: Method Wrappers. Easily possible in VW and Squeak, since you can subclass CompiledMethod and muck with the method dictionary. In VA, you have to do some additional work. Why use MethodWrappers? Niall's earliest attempts at getting at widgets as UI operations returned things made code unpredictable. Using MethodWrappers, you can:
- Wrap the #open method
- Have it not actually open, but instead just report "yes, I was about to open"
You can extend that approach to other actions the UI takes and install before/after handling/reporting. Wrappers are a way to achieve what other languages do with "policy" code.
The ideal test is like a use case test at the "top" of the model layer. Niall uses a strategy pattern to automatically wrap threads that get forked off by looking up the stack to see if the code is under test (and if it is, make sure to install a wrapper). He wraps processes, deferred messages, completion helpers, etc. In VW, there's some additional cleanup necessary to ensure that WindowManagers (for example) get "kicked". In VA, you have to drain the event queues.
Summary:
- MethodWrappers are good for UI tests
- The same tests can drive the model layer and the UI layer
- You can still do this in multi-process UIs.
A lot of thanks to various people: John Brant, Don Roberts, Michael Lucas-Smith, and Reinout Heeck.
Technorati Tags:
smalltalk, testing