四.NUnitAsp
NUnitAsp可以說是NUnitForms的兄弟,它也是一個NUnit的擴展,用來自動測試ASP.NET頁面。雖然NunitAsp可以完成一些ASP.NET頁面的自動化測試工作,但是在編寫測試用例的時候,如果界面上的元素比較多,編寫起來會非常的麻煩,這也是為什么NunitAsp一直處于大紫不紅的原因。它可以編寫如下代碼片斷的測試代碼: [Page]
public void TestLayout(){
TextBoxTester name = new TextBoxTester(\"name\", CurrentWebForm);
TextBoxTester comments = new TextBoxTester(\"comments\", CurrentWebForm);
ButtonTester save = new ButtonTester(\"save\", CurrentWebForm);
DataGridTester book = new DataGridTester(\"book\", CurrentWebForm);
Browser.GetPage(\"http://localhost/GuestBook/GuestBook.aspx\");
AssertVisibility(name, true);
AssertVisibility(comments, true);
AssertVisibility(save, true);
AssertVisibility(book, false);
}public void TestSave(){
TextBoxTester name = new TextBoxTester(\"name\", CurrentWebForm);
TextBoxTester comments = new TextBoxTester(\"comments\", CurrentWebForm);
ButtonTester save = new ButtonTester(\"save\", CurrentWebForm);
DataGridTester book = new DataGridTester(\"book\", CurrentWebForm);
Browser.GetPage(\"http://localhost/GuestBook/GuestBook.aspx\");
name.Text = \"Dr. Seuss\" comments.Text = \"One Guest, Two Guest! Guest Book, Best Book!\" save.Click();
}
學習資源
跟自己的兄弟NUnitForms一樣,仍然沒有好的中文文檔,有興趣的朋友可以參考‘NUnitAsp的官方文檔,相對來說還是比較全的,有很多的教程。
文章來源于領測軟件測試網 http://www.kjueaiud.com/