Why Opencover with MSTest does not execute and says "access is denied"? - mstest

I am using open cover with MSTest.
I am a new users and trying to get hang of Opencover.
I have tried with MSTest and MSTest is working fine with my new project in Vs2010. When I am executing following test using MStest it is working fine:
Command line run of MS Test :
MSTest /testmetadata:VoterDetails.vsmdi /testlist:DOBTest
Result:
C:\Users\<<MYuserName>>\Documents\Visual Studio 2010\Projects\VoterDetails>
MSTest /testmetadata:VoterDetails.vsmdi /testlist:DOBTest
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved.
Loading VoterDetails.vsmdi...
Starting execution...
Results Top Level Tests
------- ---------------
Passed (DOBTest/)UT_voterDOB.VoterValidationTest.validateVoterDOB
Test
1/1 test(s) Passed
Summary
-------
Test Run Completed.
Passed 1
---------
Total 1
Results file: C:\Users\<<MYuserName>>\Documents\Visual Studio 2010\Projects\VoterDetails\TestResults\<<MYuserName>>.trx
Test Settings: Local
But When I am executing following command then I am getting following result:
I am posting all combinations I have tried:
C:\Users\<<MyUserName>>\AppData\Local\Apps\OpenCover>OpenCover.Console.exe
-register:user
-target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"
-targetargs:"/testmetadata:VoterDetails.vsmdi /testlist:DOBTest"
-filter:+[VoterDetails]*
Access is denied.
C:\Users\<<MyUserName>>\AppData\Local\Apps\OpenCover>OpenCover.Console.exe
-register:-arch:32
-target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"
-targetargs:"/testmetadata:VoterDetails.vsmdi /testlist:DOBTest"
-filter:+[VoterDetails]* -output:coverage.xml
Access is denied.
C:\Users\<<MyUserName>>\AppData\Local\Apps\OpenCover>OpenCover.Console.exe
-target:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"
-targetargs:"/testmetadata:VoterDetails.vsmdi /testlist:DOBTest"
-filter:+[VoterDetails]*
-output:coverage.xml
-mergebyhash
Access is denied.

How will MSTEST know where to find VoterDetails.vsmdi when you are running in the wrong folder; try running from OpenCover from
C:\Users\<<MYuserName>>\Documents\Visual Studio 2010\Projects\VoterDetails
i.e.
C:\Users\<<MyUserName>>\AppData\Local\Apps\OpenCover>OpenCover.Console.exe -register:user ...
also -arch:32 is not a valid option for OpenCover

Related

Unable to debug .NET Core app

I'm having and issue with Visual Studio and a .NET Core API project. It's been working fine but something must have changed because I'm now getting the following output when trying to debug the project:
The program '[18032] dotnet.exe' has exited with code -2147450749 (0x80008083).
The program '[17688] iisexpress.exe' has exited with code 0 (0x0).
The program '[5500] iexplore.exe' has exited with code -1 (0xffffffff).
The event viewer is showing this error:
Failed to start process with commandline '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe" -debug -p "C:\Program Files (x86)\dotnet\dotnet.exe" -a "C:\Projects\Utilities\API\src\API\bin\Debug\netcoreapp1.0\API.dll" -pidFile "C:\Users\username\AppData\Local\Temp\tmp742C.tmp" -wd "C:\BlueSky\Utilities\API\src\API"', ErrorCode = '0x80004005'.
I'm not sure why this is happening, if anyone has any insight into this it would be appreciated.
Do as fallow:
Close Visual Studio
Delete the project.lock.json file (if exists)
If above step won't help then try to remove .vs folder
Open Visual Studio as Administrator (the file will be restored and you shouldn't have problems anymore)
There is also an option to use Kestrel instead of IIS Express but that's just an workaround.

'TestWindowPackage' package did not load correctly

I am not able to open the test Explorer
on machine had Visual Studios 2008, 2010, 2012. Then installed 2015, then 2013
Using Visual Studio 2013 update 5
'TestWindowPackage' package did not load correctly , activity log error:
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [TestWindowPackage]</description>
<guid>{BFC24BF4-B994-4757-BCDC-1D5D2768BF29}</guid>
<hr>80131509</hr>
<errorinfo>Loading MEF components failed with the following exception:
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) The specified argument cannot be empty.
Parameter name: commandContainers
Resulting in: An exception occurred while trying to create an instance of type 'Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer'.
Resulting in: Cannot activate part 'Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer'.
Element: Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer --> Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
Resulting in: Cannot get export 'Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer (ContractName="Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer")' from part 'Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer'.
Element: Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer (ContractName="Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer") --> Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
Resulting in: Cannot set import 'Microsoft.VisualStudio.TestWindow.VsHost.TestWindowPackage.PackageContainer (ContractName="Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer")' on part 'Microsoft.VisualStudio.TestWindow.VsHost.TestWindowPackage'.
Element: Microsoft.VisualStudio.TestWindow.VsHost.TestWindowPackage.PackageContainer (ContractName="Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer") --> Microsoft.VisualStudio.TestWindow.VsHost.TestWindowPackage
Additional diagnostics here:
MEF Import details for Microsoft.VisualStudio.TestWindow.VsHost.TestWindowPackage
ContractName Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
RequiredTypeIdentity Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer
Satisfied by :
Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer (ContractName="Microsoft.VisualStudio.TestWindow.VsHost.PackageContainer")
I have tried:
-Restarted Visual Studio
-Restarted PC
-Delete all files in AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
-Run VS with devenv /setup
-Run VS With devenv /setup /ResetSkipPkgs
-Repaired the VS installation
-Uninstall VS2013, Delete all visual studio files in app data, re install VS 2013 update 5
Opened ticket with Microsoft via company support account, Case number 116081014529972
They told me to reformat my machine and not install Visual Studios out of order.

Specflow running with MSTest

I am using VS2013.
I am trying to run the *.dll from the MSTest, but it fails without any execution.
If I execute the same test case manually, it always pass.
Below is the command line execution lines:
c:>"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest" /testcontainer:"E:\E_Drive\TFS_Work\PlatformSoftware\Embedded\AutomatedRe
gressionTests\Main\bin\Debug\YDOA.dll" /category:"TRLYS1D"
Microsoft (R) Test Execution Command Line Tool Version 12.0.21005.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading E:\E_Drive\TFS_Work\PlatformSoftware\Embedded\AutomatedRegressionTests\Main\bin\Debug\YDOA.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Failed YDOA.InputOutputFeature.RelayAndRelayFdbkAsUsedNormalAndFALSEAndTRUE_01
Failed YDOA.InputOutputFeature.RelayAsUnusedNormalAndALLRelaysTRUE
0/2 test(s) Passed, 2 Failed
Summary
Test Run Failed.
Failed 2
Total 2
Results file: c:\TestResults\Admin_GE-6QSVBDRLU204 2015-07-08 16_10_38.trx
Test Settings: Default Test Settings
I have the reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework" in my project.
mentioned is my AppConfig.
<specFlow>
<unitTestProvider name="MsTest"/>
<stepAssemblies>
In the SpecFlow - "Test Runner Tool", I have tried with all the options like : AUTO, ReSharper, VS2010MStest, VS2012, SpecRun....still I have the same problem.
I could not able to understand the problem.
Thanks,
Sai

How to integrate NCover and MSTest 10.0?

Using NCover Community edition, I tried:
set ncover="C:\Program Files (x86)\NCover\NCover.Console.exe"
set mstest="C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"
set testdllfolder="C:\.hudson\jobs\Project\workspace\src\TestProject\bin\Debug"
%ncover% //x coverage.xml //w %testdllfolder% %mstest% /noisolation /testcontainer:TestProject.dll
The output begins like this
Working Directory:
Assemblies:
Coverage Xml: C:.hudson\jobs\Project\workspace\src\coverage.xml
Coverage Log: Coverage.Log
Waiting for profiled application to connect...Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
and after the MSTest output
Test Run Failed.
Passed 8
Failed 2
Inconclusive 2
Total 103
Results file: C:.hudson\jobs\Project\workspace\src\debug.trx
Test Settings: Local
Connected
Profiled process terminated. Profiler connection not established.
How to fix that?
Can you post the console output to your message? That'd tell if the session completed successfully. It could be that the coverage xml isn't showing because it's going to a directory other than the one you think it should. It's default is the current command prompt directory.
Also, you may want to try using the latest edition of NCover, v.3.4.16. You can get a 21-day trial for free at www.ncover.com/download.

Build VS2010 solution on Team Build 2008 - MSTest failed to run

I have a weird problem while building VS2010 solution incl. unit tests on a Team Build 2008 server. It builds the solution and also can run the test without an error, but after running the test I get following warning which makes the build breaking:
MSBUILD : warning MSB6003: The
specified task executable "MSTest.exe"
could not be run. The system cannot
find the file specified
[C:\data\builds\FSuite\CI_Project[Debug]\BuildType\TFSBuild.proj]
The previous error was converted to a
warning because the task was called
with ContinueOnError=true. Build
continuing because "ContinueOnError"
on the task "TestToolsTask" is set to
"true".
It does not seem to be the problem that MSTest have not been found, I also checked if the TFSBuild.proj file is on this localtion - it is not missing. So what could it be?
Edit:
In meantime I figured out, that our old build server loaded and start the test assemblies once.
Task "TestToolsTask" Command:
C:\Program Files\Microsoft Visual
Studio 9.0\Common7\IDE\MSTest.exe
/nologo
/runconfig:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Sources\Sources\Products\FSuite.Debug.testrunconfig"
/searchpathroot:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug"
/resultsfileroot:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\TestResults"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.AppConfiguration.Console.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Common.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Common.UI.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Dbms.Handler.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Base.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.BusinessObjects.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Client.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Client.UI.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Enums.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Messages.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Reporting.ReportPackage.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Reporting.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.MasterStation.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.MonitoringStation.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Pac.ProductInspection.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Pac.XmlRpcProtocol.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.DomainLayer.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.Licensing.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.NotificationLayer.Tests.Unit.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Tests.Unit.Ext.dll"
/testcontainer:"C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Tests.Unit.Joint.dll"
/publish:"http://ch06sd01:8080/"
/publishbuild:"V1.0_CI_FSuite[Debug]_20100728.4"
/teamproject:"FSuite" /platform:"x86"
/flavor:"Debug" The
"TestToolsTask" task is using
"MSTest.exe" from "C:\Program
Files\Microsoft Visual Studio
9.0\Common7\IDE\MSTest.exe". Loading C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Sources\Sources\Products\FSuite.Debug.testrunconfig...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.AppConfiguration.Console.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Common.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Common.UI.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.Dbms.Handler.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Base.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.BusinessObjects.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Client.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Client.UI.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Enums.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Messages.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Reporting.ReportPackage.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Reporting.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.MasterStation.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.MonitoringStation.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Pac.ProductInspection.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Pac.XmlRpcProtocol.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.DomainLayer.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.Licensing.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Server.NotificationLayer.Tests.Unit.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Tests.Unit.Ext.dll...
Loading
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Tests.Unit.Joint.dll...
Starting execution...
Results...
2387/2387 test(s) Passed
Summary ------- Test Run Warning.
Passed 2387
------------
Total 2387 Results file: C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\TestResults\ch06-tfsservice_CH06WL2013302
2010-07-28 11_08_03_x86_Debug.trx
Run Configuration: FSuite Debug
Testconfig
Run has the following issue(s): Code coverage instrumentation warning
while processing file
MT.FSuite.Joint.Enums.dll:
TESTTOOLSTASK : warning VSP2007:
C:\data\builds\FSuite\V1.0_CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Joint.Enums.dll
contains no instrumentable code.
TESTTOOLSTASK : warning : Test Run
deployment issue: The assembly or
module
'DevExpress.RichEdit.v10.1.Core'
directly or indirectly referenced by
the test container
'c:\data\builds\fsuite\v1.0_ci_fsuite[debug]\binaries\x86\debug\mt.fsuite.tests.unit.ext.dll'
was not found. Waiting to publish...
Publishing results of test run
ch06-tfsservice#CH06WL2013302
2010-07-28 11:08:03_x86_Debug to
http://ch06sd01:8080/Build/v1.0/PublishTestResultsBuildService2.asmx...
................................Publish
completed successfully. Done executing
task "TestToolsTask".
But the new build server with VS2010 loads all test assemblies except the MT.FSuite.Tests.Unit.Joint.dll and executes the tests, which run successfully, afterwards MSTest get called again with the mentioned assembly and failes.
Command: MSTest.exe /nologo
/runconfig:"C:\data\builds\FSuite\CI_FSuite[Debug]\Sources\Sources\Products\FSuite.Debug.testrunconfig"
/searchpathroot:"C:\data\builds\FSuite\CI_FSuite[Debug]\Binaries\x86\Debug"
/resultsfileroot:"C:\data\builds\FSuite\CI_FSuite[Debug]\TestResults"
/testcontainer:"C:\data\builds\FSuite\CI_FSuite[Debug]\Binaries\x86\Debug\MT.FSuite.Tests.Unit.Joint.dll"
/publish:"http://ch06sd01:8080/"
/publishbuild:"CI_FSuite[Debug]_20100728.2"
/teamproject:"FSuite" /platform:"x86"
/flavor:"Debug" The
"TestToolsTask" task is using
"MSTest.exe" from "MSTest.exe".
I wonder why, because the test container string did not change and furthermore the second time it does not say anymore from where it gets the MSTest.exe...
Thanks for help,
Eny
OK, I've found the source of the problem. The TeamBuild targets file (C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets) has a wrong value - replace the following:
<UsingTask TaskName="TestToolsTask"
AssemblyFile="$(MSTestRefPath)\Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll"
Condition="'$(ProjectFileVersion)' == '2'" />
(the last UsingTask at line 82 if you haven't edited the file already) with:
<UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.TestToolsTask"
AssemblyFile="C:\Program Files\Microsoft Visual Studio
10.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
Condition=" '$(ProjectFileVersion)' == '2' "/>
This fixed it for me, and now my build lights are all green.

Resources