Archive for February, 2008

White

Wednesday, February 27th, 2008

The guys at Thoughtworks have released yet another open source project. This one is called white and is on codeplex http://www.codeplex.com/white/. What is white? White is a library that sits on top of the .Net 3.0 UIAutomation API’s. I have written one of these myself and we use it internally, so I haven’t looked at white.

Combined with WatiN, and ItiN if you use InfoPath, with white you should be able to write 100% of your tests using managed code in Visual Studio 2008. We do!

Another next Gen feature: XML based tests

Monday, February 4th, 2008

In my last post I gave a glimpse into our new WatiN stack, another feature is that we have implemented the command pattern, and serialise the commands out as XML. This lets us build tests that have randomised execution and still replay them when they fail. As a nice by-product, we also can write tests as XML if we wish.

Building the next generation of automated tests

Monday, February 4th, 2008

After a month of pushing my gray matter as far as it will go (which isn’t all that far compared to some of the people I know) I have implemented the next generation of automated testing on my project.

No it isn’t using excel to generate tests like some people claim, although that does have it’s place. I have implemented a stack based on the design used in the expression team as described by Michael Hunter aka “The Braidy Tester”.

This transforms a test case that was like this:

using (IE ie = new IE("http://www.google.com"))
{
    ie.TextField(Find.ByName("q")).TypeText("WatiN");
    ie.Button(Find.ByName("btnG")).Click();
    Assert.IsTrue(ie.ContainsText("WatiN"));
}

to

Logical.Search(DataProvider.GetProvider("SearchForWatin"));

The next layer down is:

public static void Search(DataProvider dataProvider)
{
    object[] parameters = {dataProvider};
    executioner.Add(parameters);
    SearchModel searchModel = new searchModel();
    searchModel.OpenSearchPage();
    VerificationManager.ActionStarting(parameters);
    searchModel.Search(dataProvider);
    VerificationManager.ActionEnding(parameters);
}

then onto the “guts” of the test in the physical model.

public void Search(DataProvider dataProvider)
{
    SearchTDO search = DataProvider.GetSearchTDO();
    controller.SetValue(Controls.Search.Google.txtSearch,
         search.SearchText);
    controller.Invoke(Controls.Search.Google.btnSearch);
}

In case you didn’t notice, WatiN is fully abstracted away out of the tests, as is the test data, verification and the intent of how things are done. This increases the complexity significantly, but it also allows us to handle changes VERY easily.