我試圖從[TestMethod]方法中顯示一些信息。如何從[TestMethod] Console.WriteLine?
通常我們使用NUnit與Console.WriteLine
運行正常,我們可以看到它在「輸出」窗口中的線,但在這個項目上,我們必須使用與VS2010和Console.WriteLine
embebed測試工具不能運行,因爲我們什麼都看不到。
我要的是展示跟蹤消息在「輸出」窗口以這種方式或多或少:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Test1
{
[TestClass]
public class TestNum1
{
[TestMethod]
public void Constructors()
{
for (int b = 1; b < 99; b++) {
Console.WriteLine(b.ToString()); // <<<<<<< This don't show on Output.
Assert.AreEqual(b, b); // This is only a silly sample.
}
}
}
}
是的,你是對的對不起我。重複的問題,但我必須添加一個註釋:您必須在調試模式下執行您的測試,或者你看不到任何輸出 – ferpega