Automated Testing for Classic ASP

Does anyone do automatic QA testing for a classic ASP site? I started looking at WatIn and MBUnit, but am not sure about the best way to structure tests.

+4
source share
3 answers

The new version of WatiN 2.0 beta 1 offers some base classes to help you structure your test classes.

It basically comes down to a class for each page (inherits from the WatiN.Core.Page class). In these page classes, you add properties for each control that you want to access. Sort of:

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

and you can create methods to transfer some more complex actions to the 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 that helps you structure your code is the Control class. When you use ASP, you will use controls that will not be displayed on only one html element on the displayed page. Instead, it is often a construct of elements contained in a div element. When you create your own Control and inheritance class Control, you can wrap internal controls (html) and behavior. This simplifies the reuse of the control in page classes. Following the example of creating an instance of the control:

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

Hopefully this gives you some insight into how you can structure your pages and controls.

Jeroen

+2
source

FWIW, we have used WatiN and MbUnit to test web integration over the past 3 years.

We divided the tests into 3 projects:

  • QA.Framework: contains glue code for setting up test instruments and various user extensions MbUnit and WatiN.

  • QA.SiteMap: contains page and control classes hierarchically organized into namespaces corresponding to different domains and parts of sites. This project allows you to separate the tests from the main part of the website structure. You can think of it as a site model.

  • QA.Tests: contains actual tests, also hierarchically ordered into namespaces. Tests use SiteMap and Framework as needed to interact with the website. Thus, there is much less code duplication than if each test contained the same mouse buttons over and over ...

Jeff.

+1
source

I tested the ASP site with Watir . If you're looking for a way to structure tests, check out the WatirCraft framework .

0
source

All Articles