2016-01-21 32 views
4

我想生成測試日誌到一個文件,我在網上找到了這個貼子,展示瞭如何使MSTest的日誌,但似乎它不工作:的Visual Studio 2015年:啓用MSTest的記錄

這裏是您應該執行以啓用MSTest日誌的步驟。

  1. 通過管理員命令提示符轉到您的MSTest安裝目錄。 (通常安裝目錄類似於C:\ Program Files \ Microsoft Visual Studio 11.0 \ Common7 \ IDE)。

  2. 打開mstest配置文件(MSTest.exe.config),並在配置節點下添加一個類似於下面所示的代碼片段。確保您指定的路徑存在,並且您有適當的權限。

**

<system.diagnostics> 
    <trace autoflush="true" indentsize="4"> 
     <listeners>     
      <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\temp\MSTest.log" /> 
     </listeners> 
    </trace> 
    <switches> 
     <!-- You must use integral values for "value". Use 0 for off, 1 for error, 2 for warn, 3 for info, and 4 for verbose. --> 
     <add name="EqtTraceLevel" value="4" /> 
    </switches> 
</system.diagnostics> 
</configuration> 

**

  • 保存配置文件,並嘗試運行測試。
  • 之後,應該生成上述路徑中的日誌文件。

    Source

    別人有同樣的問題?

    回答

    1

    嘗試增加由Ebad提出以下主要

    <system.diagnostics> 
        <switches> 
         <!-- You must use integral values for "value". 
          Use 0 for off, 1 for error, 2 for warn, 3 for info, and 4 for verbose. --> 
         <add name="EqtTraceLevel" value="4" /> 
        </switches> 
        </system.diagnostics> 
    
    ..... 
    
        <add key="CreateTraceListener" value="yes"/> 
        </appSettings> 
    </configuration> 
    
    +0

    如你所說,並沒有運氣我試圖準確。你可以在這裏發佈整個配置文件嗎? – Dilshod

    +1

    我看着這個:https://msdn.microsoft.com/en-us/library/jj159363.aspx –

    -1

    解決方案爲我工作。 但是,您需要使用MSTest而不是VStest。在命令行中運行以下

    cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ 
    .\MSTest.exe /testcontainer:C:\temp\MyTests.dll /resultsfile:testResults.trx 
    

    確保testResults.trx文件位於訪問的文件夾