Automated Acceptance Testing With NGourd and WebAii

I have written about about WebAii before. It is functional but the API sucks. I have written about NGourd too.

I am currently working on a project that is using the combination of NGourd and WebAiii for automated acceptance testing. We start with a story:

Feature: Search
    As a user
    I want to search for items
    so that I can find data that I am interested in

and then write some scenarios like:

Scenario: Search for a compensation agreement
    Given I am at the home page
    When I select the Agreements perspective
    And I search for 'agreement 1'
    Then the search results should be displayed

Within the test project we have the following directory structure:

directory

Search.feature is a text file containing the previously listed feature and scenario definitions. For each scenario step we must have a corresponding step definition. For example the step ‘When I select the Agreements perspective’ matches the following step definition:

        [Step(@"search for '([\w\s]+)'")]
        public void search_for(string searchTerm)
        {
            CurrentBrowser.Find.ById("Terms").SetValue("value", searchTerm);
            CurrentBrowser.Click(CurrentBrowser.Find.ById("search_submit"));
        }

Note the use of regular expressions to parameterise the step. Because this step is an action we put it in the ActionSteps file. Everything that we need to do for our tests falls into one of the three categories: Action, ContentAssertion or Navigation. The goal is to avoid defining the same step twice so that the set of steps form a domain specific language that can be used by business analysts and the like.

NGourd is a Cucumber knockoff, but without many of the features. However, it is surprising how far you can get with just the basics. So far it is working nicely.


Thoughts on webaii functional / web testing framework

WebAii is a proprietary, but free, functional testing framework from ArtOFTest. It has become more visible since telerik started bundling it with their ASP.NET AJAX UI Controls framework.

The Good News

The Achilles heel of most web testing tools is ajax. The good news is that webaii has more support for testing ajax applications than any of the other frameworks I have tried. Methods are provided to wait for elements, or to wait for the entire page to finish rendering. To integrate webaii into your testing project requires referencing a single dll, which is also very nice.

the bad news

CSS selectors are a well designed DSL for selecting dom elements. One of the reasons why people like jQuery so much is that it uses CSS selectors to select dom elements. Webaii uses a clunky API for dom selection. It is ok for basic selectors (by id or class) but more complex queries require dropping down to a nasty low-level API.


// jQuery: $(‘#main’)
Find.ById(“main”);

// jQuery: $(‘.myclass’)
Find.ByAttributes("class=myclass");

After writing a few smoke tests I added them into our team city continuous integration build, which broke the build. ArtOfTest do provide instructions for getting the tests to run in a build but it is complicated and requires significant changes to our build.