Testing Windows WPF Applications

I’ve been looking at WPF (Windows Presentation Foundation) applications. Although the ability to create WPF apps has been available since the release of the .NET Framework version 3.0 about a year ago, there hasn’t much WPF development because the supporting tools weren’t there. But with the release of Visual Studio 2008 and the associated .NET Framework version 3.5 a few weeks ago, I expect WPF applications will gain traction quickly. A major characteristic of WPF applications is the ability to separate UI display code from logic code; Windows applications based on .NET Framework 2.0 intermingle UI code and logic code, but with WPF applications you can have two completely separate files. The UI portion of WPF applications is based on XAML (Extended Application Markup Language) which is a type of XML. For example, consider this file named MainWindow.xaml:
<Window x:Class="SomeNamespace.MainWindow"
  Title="The Main Window" Height="250" Width="250">
  <StackPanel Margin="60">
    <Button Name="button1" Width="90" Click="button1_Click" Background="Wheat">
      Click Me
    <TextBox Name="textBox1" Width="120"/>
This file defines a simple main Window which contains a Button control and a TextBox control. This XAML file also specifies that the logic code for this application resides in a C# class named MainWindow which is part of a namespace named SomeNamespace. I put the C# code in a file named MainWindow.xaml.cs and compiled the app using the MSBuild.exe program. You can see a screenshot of the resulting app.
This is a very simple but powerful concept. The separation of UI code from logic code means, among other things, that UI development can be turned over to a graphics specialist. The specialist can use Visual Studio or more powerful design tools such as Expression, save the result as a XAML file, pass the XAML file to a developer who can then write logic code. Now from a testing point of view, the resulting application uses the new WPF-based graphics subsystem instead of the normal Win32 based subsystems, which means that normal UI test automation techniques do not work. I haven’t tried it out yet but I believe that the new MUIA test automation library can deal with WPF applications.
This entry was posted in Software Test Automation. Bookmark the permalink.