Monday, March 5, 2012

Enabling logging on MSTest.exe

Many times you might need to enable verbose logging on MSTest.exe to debug the Test related issue on the build machine.

Here are the steps

Step 1: Find the MSTest.exe.config file on the build machine. It can be found at the following location
<Drive:>\Program Files\Microsoft Visual Studio 10.0\Common7\IDE

Step 2: Make a backup copy of MSTest.exe.config file

Step 3: Add the following <system.diagnostics> in the MSTest.exe.config file
<system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="EqtListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\MSTestTrace.log" />
      </listeners>
    </trace>
    <switches>
      <add name="EqtTraceLevel" value="Verbose" />
    </switches>
  </system.diagnostics>

Step 4: Here is the sample updated file.

<?xml version ="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="PrivateAssemblies;PublicAssemblies;PrivateAssemblies\DataCollectors;PrivateAssemblies\DataCollectors\x86"/>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.UnitTestFramework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="10.1.0.0" newVersion="10.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
<system.diagnostics>
    <trace autoflush="true" indentsize="4">
      <listeners>
        <add name="EqtListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Temp\MSTestTrace.log" />
      </listeners>
    </trace>
    <switches>
      <add name="EqtTraceLevel" value="Verbose" />
    </switches>
  </system.diagnostics>
  <appSettings>
    <add key="GetCollectorDataTimeout" value="300"/>
    <add key="TestProjectRetargetTo35Allowed" value="true" />
  </appSettings>
</configuration>

Step 5: Restart the “Visual Studio Team Foundation Build Service Host” service on build machine. The next build would log the detail.

1 comment:

  1. I'm gonna try this, and if helps, I think you've rescued my headache for a week.

    ReplyDelete