2016-08-03 18 views
13
[Test] 
public void Test1() 
{ 
    Trace.TraceInformation("Hello"); 
} 

當從2015年VS運行它的輸出窗口(測試)沒有顯示出跡線:如何在NUnit 3 Visual Studio適配器中啓用跟蹤輸出?

------ Discover test started ------ 
NUnit Adapter 3.4.0.0: Test discovery starting 
NUnit Adapter 3.4.0.0: Test discovery complete 
========== Discover test finished: 9 found (0:00:01.325888) ========== 
------ Run test started ------ 
NUnit Adapter 3.4.0.0: Test execution started 
Running selected tests in C:\Projects\bla-bla.dll 
NUnit3TestExecutor converted 9 of 9 NUnit test cases 
NUnit Adapter 3.4.0.0: Test execution complete 
========== Run test finished: 1 run (0:00:03.5445181) ========== 

我記得那是工作的罰款與NUnit的2和VS 2013年我需要以某種方式將其打開?我的app.config沒有重寫默認<system.diagnostics>

回答

10

根據this的討論,他們因技術原因將其刪除。

另一種解決方案可能是這樣的:

using NUnit.Framework; 

    namespace MyUnitTest { 
     [TestFixture] 
     public class UnitTest1 { 
      [Test()] 
      public void Test1() { 
       var x = "Before Test"; 
       TestContext.Progress.WriteLine(x); 
       x = "Hello"; 
       TestContext.Progress.WriteLine(x); 
       Assert.IsTrue(x == "Hello"); 
       x = "After Test"; 
       TestContext.Progress.WriteLine(x); 
      } 
     } 
    } 

按照給定的結果:

NUnit的適配器3.4.1.0:測試執行開始使用C運行選定的測試 :\ ProjectPath \ MyUnitTest .dll NUnit3TestExecutor轉換1 of 1
NUnit測試用例測試之前測試之後你好NUnit適配器3.4.1.0:
測試執行完成
==========測試執行完成:1個運行(0:00:00,7660762)==========

結論

NUnit的輸出不能再使用Trace

+0

此行是否正常 - 「NUnit3TestExecutor轉換了9個NUnit測試用例中的9個」?它看起來像是每次都在做額外的工作,爲什麼他們「轉換」了? –

+0

我認爲這是因爲NUnit和VS測試接口不同,所以NUnit VS適配器必須「轉換」它的測試,以便VS能夠理解它們。 – UserControl

相關問題