MudassarRasool / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

MSTest not found during call made from Sonar #899

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm working with Gallio and Sonar and i'm facing an issue that I do not know 
how to solve it, I've been spent a long time doing some research, I really 
wanna call Gallio to get coverage test statistics into Sonar.

What version of the product are you using? On what operating system?

Windows Server 2008 R2 x64
Sonar 3.2
Sonar Runner 2.0
C# Ecosystem 1.4
OpenCover 4.0.804 (I knew this is not recommend, but PartCover is throwing a 
exception about a missing assembly and PartCover website is terrible)
Gallio 3.4.14.0 x64
MS Test 11 (Visual Studio 2012)

Please provide any additional information below.

18:58:55.534 INFO  d.t.c.v.ModelFactory - The project 'WebSampleApp01.Tests' 
has been qualified as a test project.
18:58:56.010 INFO  .s.b.b.ProjectModule - -------------  Analyzing WebSampleApp
18:58:56.232 INFO  .s.b.ProfileProvider - Selected quality profile : 
[name=Sonar C# Way,language=cs]
18:58:56.256 INFO  nPluginsConfigurator - Configure maven plugins...
18:58:56.293 INFO        org.sonar.INFO - Compare to previous analysis 
(2012-10-12)
18:58:56.305 INFO        org.sonar.INFO - Compare over 5 days (2012-10-07, 
analysis of 2012-10-12 14:22:44.82)
18:58:56.307 INFO        org.sonar.INFO - Compare over 30 days (2012-09-12, 
analysis of 2012-10-12 14:22:44.82)
18:58:56.398 INFO  .b.p.SensorsExecutor - Initializer ProjectFileSystemLogger...
18:58:56.402 INFO  jectFileSystemLogger - Source directories:
18:58:56.403 INFO  jectFileSystemLogger -   
C:\DefaultDir\ProgramFiles\Jenkins\jobs\ELAV-Sample2\workspace\WebSampleApp
18:58:56.404 INFO  .b.p.SensorsExecutor - Initializer ProjectFileSystemLogger 
done: 6 ms
18:58:56.404 INFO  .b.p.SensorsExecutor - Initializer 
CSharpProjectInitializer...
18:58:56.411 INFO  .b.p.SensorsExecutor - Initializer CSharpProjectInitializer 
done: 7 ms
18:58:56.460 INFO  p.PhasesTimeProfiler - Sensor 
org.sonar.plugins.csharp.core.CSharpSourceImporter@1f40e1f...
18:58:56.526 INFO  p.PhasesTimeProfiler - Sensor 
org.sonar.plugins.csharp.core.CSharpSourceImporter@1f40e1f done: 66 ms
18:58:56.526 INFO  p.PhasesTimeProfiler - Sensor 
com.sonar.plugins.csharp.squid.CSharpSquidSensor@73a35c...
18:58:56.783 INFO  p.PhasesTimeProfiler - Sensor 
com.sonar.plugins.csharp.squid.CSharpSquidSensor@73a35c done: 257 ms
18:58:56.783 INFO  p.PhasesTimeProfiler - Sensor 
org.sonar.plugins.csharp.gallio.GallioSensor@862041...
18:58:56.793 INFO  .u.c.CommandExecutor - Executing command: 
C:\DefaultDir\ProgramFiles\opencover\OpenCover.Console.exe -register:user 
-target:C:\DefaultDir\ProgramFiles\Gallio\bin\Gallio.Echo.exe 
-targetdir:C:\DefaultDir\ProgramFiles\Jenkins\jobs\ELAV-Sample2\workspace\.\.son
ar "-targetargs:\"/r:IsolatedAppDomain\" 
\"/report-directory:C:\DefaultDir\ProgramFiles\Jenkins\jobs\ELAV-Sample2\workspa
ce\.\.sonar\" \"/report-name-format:gallio-report\" \"/report-type:Xml\" 
\"C:\DefaultDir\ProgramFiles\Jenkins\jobs\ELAV-Sample2\workspace\.\WebSampleApp0
1.Tests\bin\Debug\WebSampleApp01.Tests.dll\"" "-filter:+[WebSampleApp]* " 
-mergebyhash 
-output:C:\DefaultDir\ProgramFiles\Jenkins\jobs\ELAV-Sample2\workspace\.\.sonar\
coverage-report.xml
18:58:57.388 INFO  .u.c.CommandExecutor - 
18:58:57.423 INFO  .u.c.CommandExecutor - Gallio Echo - Version 3.4 build 11
18:58:57.424 INFO  .u.c.CommandExecutor - Get the latest version at 
http://www.gallio.org/
18:58:57.424 INFO  .u.c.CommandExecutor - 
18:58:57.489 INFO  .u.c.CommandExecutor - Start time: 18:58
18:58:57.588 INFO  .u.c.CommandExecutor - Initializing the runtime and loading 
plugins.
18:58:58.253 INFO  .u.c.CommandExecutor - Verifying test files.
18:58:58.337 INFO  .u.c.CommandExecutor - Initializing the test runner.
18:58:58.363 INFO  .u.c.CommandExecutor - Running the tests.
18:59:02.797 INFO  .u.c.CommandExecutor - [error] Assembly WebSampleApp01.Tests
18:59:02.797 INFO  .u.c.CommandExecutor - Cannot run tests because the MSTest 
executable was not found
18:59:02.797 INFO  .u.c.CommandExecutor - 
18:59:02.836 INFO  .u.c.CommandExecutor - Generating reports.

Original issue reported on code.google.com by rodrigost on 13 Oct 2012 at 12:03

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

just install the Visual Studio Test Agent 2010 package from here: 
http://www.microsoft.com/en-us/download/details.aspx?id=1334

Original comment by fmarcel...@gmail.com on 7 Dec 2012 at 3:29

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Why installing the Agent is the agent used if you are running the test in 
different computer ?

Original comment by argtonra...@gmail.com on 13 Nov 2013 at 7:57

GoogleCodeExporter commented 8 years ago
I installed Visual Studio Test Agent 2010 from the location, I still get the 
same error message.

Visual Studio 2013 Ultimate
SONAR 3.7.3
Sonar-runner 2.2.2
OpenCover 4.5.1313 
GallioBundle-3.4.14.0 

Here is the error I get.

13:12:52.818 INFO  - [error] Assembly *****.Tests
13:12:52.818 INFO  - Cannot run tests because the MSTest executable was not 
found

Original comment by kishornp...@gmail.com on 29 Dec 2013 at 4:46

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I could get the test case execution successful with this setup (I did see the 
test case execution successful in gallio report), but I do not see the coverage 
numbers in SONAR dashboard:

Visual Studio 2013 Ultimate
SONAR 3.7.3
Sonar-runner 2.2.2
OpenCover 4.5.1313 
GallioBundle-3.4.14.0 
Visual Studio Test Agent 2010

I had to add registry key "InstallDir" 

I have following exception in the log file, I think that is preventing from 
getting the coverage numbers in SONAR dashboard:

01:43:15.848 INFO  - Internal error: An unhandled exception occurred in thread 
'DataCollectionAgentObject.InitializeDataCollectorCache'.
01:43:15.848 INFO  - The exception occurred while test step 'Employee.Tests' 
was running.
01:43:15.848 INFO  - System.Threading.ThreadAbortException: Thread was being 
aborted.
01:43:15.848 INFO  - HResult: -2146233040
01:43:15.848 INFO  -    at 
Microsoft.VisualStudio.TestTools.Diagnostics.RemoteEqtTrace.set_TraceLevel(Trace
Level value)
01:43:15.848 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.PerformDiscovery()
01:43:15.848 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.ForceCacheUpdate()
01:43:15.848 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.GetAllCollectorInf
ormation()
01:43:15.848 INFO  -    at 
Microsoft.VisualStudio.TestTools.Agent.DataCollectionAgentObject.<InitializeData
CollectorCache>b__b(Object state)
01:43:15.848 INFO  -    at 
System.Threading.ThreadHelper.ThreadStart_Context(Object state)
01:43:15.848 INFO  -    at 
System.Threading.ExecutionContext.RunInternal(ExecutionContext 
executionContext, ContextCallback callback, Object state, Boolean 
preserveSyncCtx)
01:43:15.848 INFO  -    at 
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, 
ContextCallback callback, Object state, Boolean preserveSyncCtx)
01:43:15.848 INFO  -    at 
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, 
ContextCallback callback, Object state)
01:43:15.848 INFO  -    at System.Threading.ThreadHelper.ThreadStart(Object obj)

Original comment by kishornp...@gmail.com on 30 Dec 2013 at 9:05

GoogleCodeExporter commented 8 years ago
According some Galio's restrictions, it needed changing the machine.config 
file, usually its being located at 
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\". On that adding the 
following change:
<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>

Another step is modify the Window's Registry by adding for InstallDir a new 
value. It has to be like this:
InstallDir => C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\

Finally, the last step is garanty compatibility with OpenCover 32bits into 
Windows throw the command:

regsvr32 "C:\YourSonarInstalation\opencover\x86\OpenCover.Profiler.dll.

When I had completed all this step, Sonar has been work very fine.

I hope yours also work.

Thanks.

Original comment by rodrigost on 30 Dec 2013 at 1:45

GoogleCodeExporter commented 8 years ago
Can you share the Registry Key path?

Original comment by zacharia...@gmail.com on 3 Jan 2014 at 12:29

GoogleCodeExporter commented 8 years ago
Here we 
are...\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0
InstallDir 

Original comment by rodri...@ciandt.com on 3 Jan 2014 at 12:41

GoogleCodeExporter commented 8 years ago
I followed all the steps as per your instructions.

InstallDir -> C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE

Updated "machine.config" in two locations :
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.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.30319.1"
                   newVersion="12.0.25001.1"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>  

Registered :

C:\Users\a342228\AppData\Local\Apps\OpenCover\x86\OpenCover.Profiler.dll

I still get the exception I was getting before :

23:40:01.342 INFO  - Internal error: An unhandled exception occurred in thread 
'DataCollectionAgentObject.InitializeDataCollectorCache'.
23:40:01.342 INFO  - The exception occurred while test step 'Employee.Tests' 
was running.
23:40:01.342 INFO  - System.Threading.ThreadAbortException: Thread was being 
aborted.
23:40:01.342 INFO  - HResult: -2146233040
23:40:01.342 INFO  -    at 
Microsoft.VisualStudio.TestTools.Diagnostics.RemoteEqtTrace.set_TraceLevel(Trace
Level value)
23:40:01.342 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.PerformDiscovery()
23:40:01.342 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.ForceCacheUpdate()
23:40:01.342 INFO  -    at 
Microsoft.VisualStudio.TestTools.Execution.DataCollectorCache.GetAllCollectorInf
ormation()
23:40:01.342 INFO  -    at 
Microsoft.VisualStudio.TestTools.Agent.DataCollectionAgentObject.<InitializeData
CollectorCache>b__b(Object state)
23:40:01.342 INFO  -    at 
System.Threading.ThreadHelper.ThreadStart_Context(Object state)
23:40:01.342 INFO  -    at 
System.Threading.ExecutionContext.RunInternal(ExecutionContext 
executionContext, ContextCallback callback, Object state, Boolean 
preserveSyncCtx)
23:40:01.342 INFO  -    at 
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, 
ContextCallback callback, Object state, Boolean preserveSyncCtx)
23:40:01.342 INFO  -    at 
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, 
ContextCallback callback, Object state)
23:40:01.342 INFO  -    at System.Threading.ThreadHelper.ThreadStart(Object obj)

Here is Gallio command:

23:39:22.561 DEBUG - Executing Gallio program...
23:39:22.562 DEBUG - - Gallio executable   : C:\Program 
Files\Gallio\bin\Gallio.Echo.exe
23:39:22.562 DEBUG - - OpenCover executable: 
C:\Users\a342228\AppData\Local\Apps\OpenCover\OpenCover.Console.exe
23:39:22.563 DEBUG - - Coverage tool       : OpenCover
23:39:22.563 DEBUG - - Runner              : ISOLATED_PROCESS
23:39:22.563 DEBUG - - Report directory    : C:\Test\Company\.sonar
23:39:22.563 DEBUG - - Report file         : gallio-report
23:39:22.563 DEBUG - - Test assemblies     :
23:39:22.563 DEBUG -    o 
C:\Test\Company\Employee.Tests\bin\Debug\Employee.Tests.dll
23:39:22.563 DEBUG - - Working directory   : C:\Test\Company\.sonar
23:39:22.563 DEBUG - - Opencover include   : [Company]*
23:39:22.563 DEBUG - - Opencover include   : [Employee]*
23:39:22.563 DEBUG - - Coverage report     : 
C:\Test\Company\.sonar\coverage-report.xml
23:39:22.563 INFO  - Executing command: 
C:\Users\a342228\AppData\Local\Apps\OpenCover\OpenCover.Console.exe 
-register:user -target:C:\Program Files\Gallio\bin\Gallio.Echo.exe 
-targetdir:C:\Test\Company\.sonar "-targetargs:\"/r:IsolatedProcess\" 
\"/report-directory:C:\Test\Company\.sonar\" 
\"/report-name-format:gallio-report\" \"/report-type:Xml\" 
\"C:\Test\Company\Employee.Tests\bin\Debug\Employee.Tests.dll\"" 
"-filter:+[Company]* +[Employee]* " -mergebyhash 
-output:C:\Test\Company\.sonar\coverage-report.xml
23:39:23.075 INFO  - Executing: C:\Program Files\Gallio\bin\Gallio.Echo.exe

Original comment by kishornp...@gmail.com on 3 Jan 2014 at 5:49

GoogleCodeExporter commented 8 years ago
Finally it worked using the solution approach. Thanks "rodrigost" :)

Original comment by kishornp...@gmail.com on 12 Feb 2014 at 4:58

GoogleCodeExporter commented 8 years ago
Hi there

So I occured the same problem in first post. I followed all steps, but still 
have

the same error log

08:37:15.070 INFO  - Running the tests.
08:37:26.742 INFO  - [error] Assembly *********
08:37:26.742 INFO  - Cannot run tests because the MSTest executable was not foun
d
08:37:26.742 INFO  -
08:37:27.039 INFO  - Generating reports.
08:37:28.851 INFO  - Disposing the test runner.
08:37:28.851 INFO  - Stop time: 8:37 AM (Total execution time: 15.764 seconds)
08:37:28.851 INFO  -
08:37:28.867 INFO  - 1 run, 0 passed, 1 failed (1 error), 0 inconclusive, 0 skip
ped

it's only a test project but soon I'll need to do the same thing on a larger 
one, so I need to know how it's done right. 

Where in the config should I put this  lines

<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>

In the end or mb in a some specific place?
Do I must put the changes in to 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config  too?

I've installed Visual Studio Test Agent 2012 package or I need the 2010??

Will be w8 for your help ^^

Original comment by iiiiii...@gmail.com on 25 Apr 2014 at 4:05

GoogleCodeExporter commented 8 years ago
I believe this solution only works with  Visual Studio 2010 Test agent only.

Original comment by kishornp...@gmail.com on 4 May 2014 at 3:52

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
i am also getting same error "MSTest not found during call made from Sonar" 
using gallio. Any other solutions ?

Original comment by g9848921...@gmail.com on 16 Sep 2014 at 5:49

GoogleCodeExporter commented 8 years ago
The latest version of Gallio was released back in 2012, and seems that it works 
only with VS2010. If you have VS2012 or 2013 isntalled, you'd have to make it 
think that VS2010 is installed instead.

One quick way is to patch the Windows Registry by creating one dummy.reg file 
for example with following content:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0]
"InstallDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 
11.0\\Common7\\IDE\\"
@=""
"MsEnvLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 
11.0\\Common7\\IDE\\msenv.dll"
"ApplicationID"="VisualStudio"
"StartMenuFolder"=""
"ShellFolder"="C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\"
"EnablePreloadCLR"=dword:00000001
"RestoreAppPath"=dword:00000001
"CLR Version"="v4.0.30319"
"SetupCommandLine"="/Setup"

Right-click the file in Windows Explorer to merge it with the registry, and 
then any MSTEST calls from Gallio will be redirected to your VS2012/2013 
version instead.

Original comment by happypup...@gmail.com on 21 Oct 2014 at 6:05

Attachments:

GoogleCodeExporter commented 8 years ago
If you are using VS2013, you just need to change the string "Microsoft Visual 
Studio 11.0" to "Microsoft Visual Studio 12.0" instead.

Original comment by happypup...@gmail.com on 21 Oct 2014 at 6:22

GoogleCodeExporter commented 8 years ago
Here you go --- the whole story to make it work with VS2012 and 2013.

http://scissortools.wordpress.com/2014/10/21/how-to-make-sonar-runner-work-with-
visual-studio-2012-and-2013/

Original comment by happypup...@gmail.com on 21 Oct 2014 at 9:59