« February 2008 | Main | April 2008 »

March 24, 2008

Unit Testing User Interfaces - Introduction

You may have caught my last series in which I looked at six different patterns for organising view logic in a Flex client. In this series I'm going to take the demonstration applications for three of those patterns and look at the changes required to effectively unit test them. The aim of the exercise is to gain an insight into how amenable each pattern is to unit testing and hopefully wrestle with some common unit testing challenges along the way.

What is unit testing?

This isn't an introduction to unit testing or a tutorial on how to get started with unit testing. So if you're asking this question you may want to have a look at some of the links below. The test tool of choice for this series is Flex Unit as it is the one we use on our consulting projects. There are others out there, so feel free to shop around.

The plan

When looking at Presentation Patterns I started with the simplest pattern to implement, but for this series I'm going to start with the pattern that I believe will be simplest to unit test. So here's the order of business:

  1. Presentation Model
  2. Supervising Presenter
  3. Autonomous View

Why test view logic?

Applying a unit testing strategy to your user interface logic can have more than one advantage:

Is this Test Driven Development?

Test Driven Development (TDD) or test-first development is a development practice in which unit tests are written before the code they test. The advantage of TDD is that the test is seen to fail before the code is written, and the code is then written to make the test pass. I'm not following a TDD approach in these entries because the applications I'm testing have already been written.

In my next entry I'll take a look at unit testing my Presentation Model example.

Posted by paulw at 01:25 PM | Comments (0) | TrackBack