我有一个TestMethod
将遍历所有包含特定用户控件的页面。我遇到的问题是,当/如果我的断言失败时,我无法在错误消息或堆栈跟踪中看到它失败的页面。有没有办法自定义或添加其他参数以显示在测试结果详细信息中?
并不是真的需要它,但这是我的代码......
[TestMethod]
public void uiTestCourseListingPages() {
UiBrowserWindow uiBrowserWindow = new UiBrowserWindow();
string controlType = "~/_control/course/courseList.ascx";
var request = WebRequest.Create(Utility.GET_PAGES_WITH_CONTROL_URL + controlType);
request.ContentType = "application/json; charset=utf-8";
using(var response = request.GetResponse()) {
using(var streamReader = new StreamReader(response.GetResponseStream())) {
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<PagesWithControl> pagesWithControl = serializer.Deserialize<List<PagesWithControl>>(streamReader.ReadToEnd());
pagesWithControl.ForEach(x => {
// launch browser
uiBrowserWindow.launchUrl(x.key);
// setup assertions
Assert.AreEqual(
uiBrowserWindow.uiHtmlDocument.searchHtmlElementByAttributeValues<HtmlDiv>(new Dictionary<string, string> {
{HtmlDiv.PropertyNames.Class, "footer"}
}).Class,
"footer"
);
});
}
}
}