Testing ASP.NET Pages
I've been working on getting ad hoc tests working with ASP.NET. In order to work, the code behind class must be annotated with several attributes. They let the test runner know which page to render, what query string to use and when to run the test. The test can be run during any page event (Init, Load, DataBinding, PreRender etc.). For example, say you right click on and run the following 'test()' method....
The following would appear in the test output window...[Page("Test.aspx")]
public class Test : System.Web.UI.Page{
private void Page_Load(object sender, System.EventArgs e){
Debug.WriteLine("Page_Load");
}
[Query("name=value"), Event("PreRender")]
private void test(){
Debug.WriteLine("debug output...");
Debug.Assert(Request.QueryString["name"] == "value");
}
#region
Web Form Designer generated code}
------ Test started: Assembly: TestWebProject.dll ------
Page_Load
debug output...
file:///C:/CVSHOME/NUnitAddin/TestWebProject/Test.aspx.htm1 succeeded, 0 failed, 0 skipped, took 0.00 seconds.
---------------------- Done ----------------------
I would be interested to know how people are testing their ASP.NET pages today. I'm also open to suggestions as to how this feature should work. At the moment it's just for individual ad hoc tests. I'm wondering how to enable it for whole test suites. Drop me a line if you have any suggestions or would like to play with the latest revision (I'm afraid a build still isn't up).
P.S. I'm still looking for someone to help test the Mono & Rotor support. I need someone to go though the configuration procedure to flush out any issues. Does anyone fancy a play with Mono? ;o)