Mar 4, 2005 / NUnitASP Problems

1 comments
I've tried NUnitASP to test ASP.NET web pages in TargetProcess project. As usual, there are some problems with tool adoption. All these issues have been resolved, but I am not satisfied with solutions and stop using NUnitASP for now. I want to find a better way.

Tests Independence & Database State

To keep tests independent, web application should be in known initial state before every test

The TargetProcess system uses database, so the database should be in the same state before each test. I can't find a better way than executing bat file from command line in [SetUp] method. The bat file contains something like this: osql -U sa -P -d dbname -i D:\TargetProcess\src\Tp.Model\Sql\testData.sql

This works. Not as fast as I want, but I can wait a minute or two. When database become bigger, this solution might be unacteptable.

Dynamic Controls Insertion and NUnitASP

Most of the server controls inserted dynamically on run-time in TargetProcess. This cause additional problems, since controls ids may change. For example, new TargetProcess' module will insert additional control on dashboard. And I should update many already defined Ids in tests. Here is code sample:

protected override void SetUp()
{
  SetInnocentState();

  control = new UserControlTester("_ctl4", CurrentWebForm);

  ddFilterByIteration = new DropDownListTester("ddFilterByIteration", control);
  btnUpdate = new ButtonTester("btnUpdate", control);

  dgUserStories = new DataGridTester("dgUserStories", control);
  row = dgUserStories.GetRow(0);

  ddIterations = new DropDownListTester("ddIterations", row);
 
  lbChangeStatus = new LinkButtonTester("lbChangeStatus", row);
  lbDelete = new LinkButtonTester("lbDelete", row);

  Browser.GetPage("http://tp/Tp.Web/Project/1/Planning/UserStories/List.aspx");
}


[Test]
public void ListView()
{
   string[] expected = new string[]
       {"Text. Will not check it", "12", "Great"};

   AssertEquals(expected[1], dgUserStories.GetRow(0).TrimmedCells[1]);
   AssertEquals(expected[2], dgUserStories.GetRow(0).TrimmedCells[2]);
   AssertEquals("- Iteration? -", ddIterations.SelectedItem.Text);
   AssertEquals("Done", lbChangeStatus.Text);
}

[Test]
public void FilterList()
{
   ddFilterByIteration.Items[1].Selected = true;
   AssertEquals("Iteration #1", ddIterations.SelectedItem.Text);
   ddFilterByIteration.Items[0].Selected = true;
   AssertEquals("- Iteration? -", ddIterations.SelectedItem.Text);
}

In code control = new UserControlTester("_ctl4", CurrentWebForm) real base control id is "_ctl4". But when add new control on the top of this, its id will be "_ctl5". This is a major issue for now.

1 Comments:

At 10:47 AM, Anonymous Anonymous said...

Check out Ruby/Watir. We're using it at our company, and while it takes a little work to get configured (mostly it's because we used Cassini instead of Apache), it works pretty well.

 

Post a Comment

<< Home

Subscribe to the RSS feed
Stay tuned by having the latest updates via RSS
Follow TargetProcess on Twitter
Get in touch with our team

TargetProcess is an agile project management tool. It is designed to solve distributed teams problems and support agile development processes.



Key Features

  • Full Agile Project Management Support (Scrum, XP, Custom)
  • Productivity Tools (Tp.Tray, ToDo list, dashboards, Inline editing)
  • Customizable Development Process
  • Subversion Integration
  • Integrated Bug Tracking, Help Desk, Time Tracking

Get TargetProcess for Free (5 users pack)

Previous Posts



    follow me on Twitter