Question

I've got an annoying issue with Gallio when I try to analyse my VS2012 C# solution with my sonar-runner. When Gallio try to launch my unit test I can find this issue in the logs :

  [error] Assembly XXXX   
  Cannot run tests because MSTest executable was not found

I've already tried some propositions of solution exposed here and here (I have installed Agents for VS 2012 and I have added a registry key with the path of my VS2012 installation) but nothing seems to work.

Thank you by advance for your help.

EDIT :

It seems that this issue come from an hard coded registry value in Gallio source code because when I try to add the InstallDir registry key for VS2010 to point to my VS2012 installation I can see a new error message.

This new error is an I/O Exception relative to the following DLL : "Microsoft.VisualStudio.QualityTools.CommandLine.dll" version 10.0.0.0 which I'm able to find in my GAC_MSIL directory but in version 11. My conclusion is that Gallio isn't fully compatible with VS2012 and the corresponding version of MSTest.

I'm going to investigate to find a way to manually generate Unit testing reports that Sonar will be able to store.

EDIT 2 :

There is finally no way to collect mstest reports in sonar for now. The only solution I found is to convert every unit test made with MSTest into an NUnit test to be able to run it with gallio and gather the results in my Sonar server.

Was it helpful?

Solution

Add the following to your machine.config located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.CommandLine"
                publicKeyToken="b03f5f7f11d50a3a"
                culture="neutral" />
      <bindingRedirect oldVersion="10.0.0.0"
               newVersion="11.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Then you will need to add a registry key called InstallDir with a value of "InstallDir => C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\" to the following location HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0

Then run the following command regsvr32 "C:\YourSonarInstalation\opencover\x86\OpenCover.Profiler.dll

The issue is being discussed here. The potential solution above was posted a few days ago. https://code.google.com/p/mb-unit/issues/detail?id=899

OTHER TIPS

For Visual Studio 2013 and .net 4.5 This is a similar process.

Add the following to your machine.config located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config and/or C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config:

    <runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.CommandLine"
                publicKeyToken="b03f5f7f11d50a3a"
                culture="neutral" />
      <bindingRedirect oldVersion="10.0.0.0"
               newVersion="12.0.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

Then you will need to add a registry key called InstallDir with a value of "InstallDir => C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\" to the following location HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0

Then run the following command regsvr32 "C:\Program Files (x86)\OpenCover\x86\OpenCover.Profiler.dll"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top