[英]Making a custom Log During Coded Ui Test Run
基本上,我正在使用MStest運行一組編碼的ui測試。
我正在嘗試在測試運行時編寫自定義日志文件。
例如,在每次測試結束時,如果測試通過,我想在文本文件中添加一行,內容為“測試已通過”
最好將其發送到TXT文件。 通過擴展,我最終會將其輸出到電子郵件中,但是現在不需要了。
在每個測試結束時的基本水平上,我正在嘗試
if (this.testContextInstance.CurrentTestOutcome.Equals(true))
{
string lines = "Passed.";
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt");
file.WriteLine(lines);
file.Close();
}
else
{
string lines = "Failed.";
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt");
file.WriteLine(lines);
file.Close();
}
}
但是我不完全了解CurrentTestOutcome方法。
目前,我根本沒有任何文件輸出。
CurrentTestOutcome
是一個枚舉,請參見http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcontext.currenttestoutcome.aspx和http://msdn.microsoft.com/en-us/library /microsoft.visualstudio.testtools.unittesting.unittestoutcome.aspx 。 所以我不確定問題的this.testContextInstance.CurrentTestOutcome.Equals(true)
實現什么。
如下所示應顯示您想要的內容:
string lines = "Failed.";
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\test.txt");
file.WriteLine(this.testContextInstance.CurrentTestOutcome.ToString());
file.Close();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.