I have a TestMethod that will loop through all pages that contain a certain user control on them. The issue I’m running into is that when/if my assertion fails I’m not able to see the page it failed on in the error message or stack trace. Is there a way to customize or add in additional parameters to be shown in the test results details?
Not that it’s really needed, but here’s my code…
[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"
);
});
}
}
}
There is an overloaded Assert.AreEqual(object,object,string). If you put the URL into the string that would show up in the test results.