1
我使用NUnit的262和2010年VSNUnit的沒有顯示調試消息在其窗口
此代碼應顯示在NUnit的窗口的Debug.WriteLine writen消息,但它doen't。
代碼:
public interface ILongRunningLibrary {
string RunForALongTime(int interval);
}
public class LongRunningLibrary : ILongRunningLibrary {
public string RunForALongTime(int interval) {
var timeToWait = interval * 1000; Thread.Sleep(timeToWait);
return string.Format("Waited {0} seconds", interval);
}
}
[TestFixture]
public class MoqExamples {
private Mock<ILongRunningLibrary> _longRunningLibrary;
[SetUp]
public void SetupForTest() {
_longRunningLibrary = new Mock<ILongRunningLibrary>();
}
[Test]
public void TestLongRunningLibrary() {
const int interval = 10;
var result = _longRunningLibrary.Object.RunForALongTime(interval);
Debug.WriteLine("Return from method was '" + result + "'");
}
[TearDown]
public void TearDownAfterTest() {
}
}
我應該可以看到這個在NUnit的窗口:
但我看到這個:
是的,我查了一下,但該標籤中沒有任何消息。該標籤甚至是灰色的,就好像它被禁用了一樣! – Rafael
是否可以用Console.WriteLine替換Debug.WriteLine?而且這樣做甚至工作嗎? –
是的,它的工作。謝謝 – Rafael