Asp – Automated testing for Classic ASP

asp-classicautomated-testsmbunitwatin

Does anyone do automated QA testing for a Classic ASP site? I started looking at WatIn and MBUnit but not sure of the best way to structer the tests.

Best Answer

The new WatiN 2.0 beta 1 does offer some base classes to help you structure test classes.

It basically comes down to having a class for each page (inheriting the WatiN.Core.Page class). In these page classes you add properties for each control you want to access. Something like:

public Button OkButton
{
    get { return Document.Button("okbuttonId");
}

and you can create methods to wrap some more complicated actions an a page. For instance:

public void AddPerson(string name, string email)
{
    /// logic goes here tp click on NewButton, set the textfields and click on OkButton
}

These page classes offer the advantage of defining your elements in one place.

In your test code you can create a page class as follows:

using(var ie = new IE("www.somedomain.com/person"))
{
  var page = ie.Page<PersonDetailPage>();
  page.AddPerson("J. Doe", "jdoe@example.com");

  // Do some Assert
}

Another interesting base class to help you structure your code is the Control class. When you use ASP you'll use controls which will not render to just one html element in the rendered page. Instead it will often be a construct of elements contained in a Div element. When creating your own control class and inherit Control you'll be able to wrap the controls (html) internals and behavior. This makes it very easy to reuse the control in your page classes. Following an example on how to instantiate a control:

var calendar = Document.Control<CalendarControl>("calendarId");

Hope this gives you some insight in how you can structure your Pages and controls.

Jeroen

Related Topic