IcuTest
Encyclopedia
IcuTest is a unit testing framework for GUIs. The current version supports Windows Presentation Foundation
Windows Presentation Foundation
Developed by Microsoft, the Windows Presentation Foundation is a computer-software graphical subsystem for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0. Rather than relying on the older GDI...

 applications. GUI verification is done primarily using image comparisons. Test suites can run interactively or fully automated.

Philosophy

IcuTest is not a record-and-playback system. Such systems can produce test scripts that are difficult to maintain. Rather, IcuTest believes that the most effective place to test is within the unit test. Hence, IcuTest forgoes any recording mechanism and, like typical unit tests, relies on the programmer to define the scope and parameters of the test.

Usage

A typical IcuTest provides direct control of the app under test. Here is an example that ensures that the ViewModel is correct.


[TestMethod]
public void TestMyWindow_WithDataContext
{
ICU.Invoke( => {
var w = new MyWindow;
w.Show;
ICU.CheckView(w, "MyWindowTest");

w.DataContext = new MyViewModel;
ICU.CheckView(w, "MyWindowTest_with_ViewModel");

w.Close;
});
}


ICU.CheckView is the main testing (or Assert) mechanism in IcuTest. It performs a fast bitmap comparison between the current UI snapshot and a previously stored snapshot. Like an Assert, CheckView throws an exception when a test fails.

IcuTest offers higher level tools specifically designed to help GUI testing. Here is an example that illustrates:
  • IcuTest Scenarios
  • Coded UI automation
  • BDD (Behavior Driven Development
    Behavior driven development
    Behavior-driven development is an agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project...

    ) support
  • GWT (Given, When, Then) and AAA (Arrange, Act, Assert) fluency



[TestMethod]
public void cannot_login_with_invalid_password
{
var context = new WindowScenario;
ICU.Given(context)

// Optional BDD specs
.AsA("MyApp User")
.IWant("a login window")
.SoThat("I have secure access to MyApp data")

.When( => {
// set wrong password using GUI automation
set_login(context.Window, "myname", "wrong password");
})
.Then( => {
// window should display "invalid login" message
ICU.CheckView(context.Window, "login_with_invalid_pass");
})
.Test;
}

void set_login(ExampleLoginWindow w, string user, string pass)
{
var userBox = guiHelper.Find(w, "userBox");
var passBox = guiHelper.Find(w, "passwordBox");
var loginBtn = guiHelper.Find
 
x
OK