我正在使用NUnit 262和VS 2010。
此代码应显示在NUnit窗口中使用Debug.Writeline写入的消息,但它不会。
代码:
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窗口中看到这个:
但我明白了这一点:
答案 0 :(得分:1)
使用Console.WriteLine
时,您会在测试运行器底部的Text Output
标签中看到输出。我不确定Debug.WriteLine
是否也将它放在那里。你检查过了吗?