2013-06-27 93 views
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的窗口:

a busy cat

但我看到這個:

a busy cat

回答

1

當使用Console.WriteLine ,你會看到的e測試運行器底部的Text Output選項卡中輸出。我不確定Debug.WriteLine是否也可以。你檢查過了嗎?

+0

是的,我查了一下,但該標籤中沒有任何消息。該標籤甚至是灰色的,就好像它被禁用了一樣! – Rafael

+0

是否可以用Console.WriteLine替換Debug.WriteLine?而且這樣做甚至工作嗎? –

+0

是的,它的工作。謝謝 – Rafael