There are a bunch of basic quality checks that should happen on every web page that goes live and they are tedious to do manually. I am working on a few helpers to integrate these checks into an xUnit test suite for projects:
[TestFixture]
public class ExampleTests
{
static readonly TimeSpan maxResponseTime = TimeSpan.FromSeconds(5);
const int maxHtmlSize = 51200;
const int maxViewState = 4096;
[RowTest]
[Row("http://www.microsoft.com/")]
[Row("http://www.asp.net/")]
[Row("http://www.myspace.com/")]
public void BasicWebPageQualityChecks(string url)
string html = null;
TimeSpan responseTime = TimeTakenToExecute(() =>
html = GetResponse(url);
});
Assert.That(responseTime, Is.LessThan(maxResponseTime));
Assert.That(html.Length, Is.LessThan(maxHtmlSize));
Assert.That(html, HasViewState.LessThan(maxViewState));
Assert.That(html, Validates.AsXHtml10Transitional);
}
I have used the RowTest extension for NUnit as an example of how to test a number of URLs with as little fuss as possible. The test is intended to sit alongside functional Watin style tests and be a basic check to stop developers handing rubbish off to QA. There are lots of ways to structure the test but keep the following in mind:
I'm interested to hear from you if you have any feedback or suggestions for similar things you'd like to be able to check. I intend to push this out as a simple .dll you can link against where needed.
Labels: ASP.Net, TDD