NUnit未在其窗口中显示调试消息

时间:2013-06-27 14:21:35

标签: visual-studio-2010 nunit moq

我正在使用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窗口中看到这个:

a busy cat

但我明白了这一点:

a busy cat

1 个答案:

答案 0 :(得分:1)

使用Console.WriteLine时,您会在测试运行器底部的Text Output标签中看到输出。我不确定Debug.WriteLine是否也将它放在那里。你检查过了吗?