Unit testing through the UI

One of my readers asked whether there were any UI unit testing tools.

While I have seen some ASP.net tools like this, in general I’d expect that you would unit test a UI by making the UI a very thin layer (one that doesn’t really need testing), and writing the unit tests to talk to the layer underneath.

Though I haven’t had the opportunity to try it on a full project, I think that Presenter First has a lot going for it.

Comments (3)

  1. rob says:

    for asp.net watin is very good.  for winforms and wpf I don’t know of a good solution.

  2. Michael Bone says:

    A Windows forms unit testing tool is NUnitForms:


    And just for reference there’s a stream of do-it-yourself Windows forms UI testing articles on MSDN (eg. the first one makes use of "Active Accessibility" in .NET 3.0):

    http://msdn.microsoft.com/msdnmag/issues/07/03/Bugslayer  "GUI Control to Major Tom"

    http://msdn.microsoft.com/msdnmag/issues/06/04/ManagedSpy  "Managed Spy"

    http://msdn.microsoft.com/msdnmag/issues/05/09/testrun  "Low-Level UI Test Automation"

    http://msdn.microsoft.com/msdnmag/issues/05/01/TestRun  "Lightweight UI Test Automation with .NET"

    http://msdn2.microsoft.com/en-us/library/ms996405.aspx  "Automating Windows Forms"

    In general, though, I think Windows forms unit testing is a hard problem to solve.  All the tools I’ve seen struggle in one way or another (eg. with timing issues, control positions, identifying control names, etc.).