1

I'm using NUnit 262 and VS 2010.

This code should show messages writen with Debug.Writeline in the NUnit window, but it doen't.

The code:

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() {
    }
}

I should see this in the NUnit window:

a busy cat

But I see this instead:

a busy cat

4

1 回答 1

1

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

于 2013-06-27T16:06:56.080 回答