Bug Report T732938
Visible to All Users

Unit Testing – Code Coverage does not support MSTests in Visual Studio 2019

created 6 years ago

The Test Runner runs fine without coverage, but "Run all, with coverage" shows errors. See messages from Output window below.

- The Test project is configured for .NET Framework 4.7
- The nuget packages MSTest.TestFramework v1.4.0 and MSTest.TestAdapter v1.4.0 are loaded

Apparently the assembly Microsoft.VisualStudio.TestPlatform.Core, Version=14.0.0.0 is missing.

My output directories (Debug and Release) list:
    Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
    Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
    Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
    Microsoft.VisualStudio.TestPlatform.TestFramework.dll
the one with .Core is missing.

Messages from Output window  for Test Runner

>>>>
Test started…
Can not start test framework provider.
Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Type: System.Reflection.ReflectionTypeLoadException
Source: mscorlib
StackTrace:    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionService.SatisfyImportsOnce(ComposablePart part)
   at DevExpress.CodeRush.TestRunner.Core.TestRunnerCompositionService.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
   at DevExpress.CodeRush.TestRunner.Executor45.DefaultTestFrameworkExecutorProvider.GetTestFrameworkExecutor(String runnerAssembly)
Message: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
Source:
StackTrace:
Message: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
Source:
StackTrace:

Can not start test framework provider.
Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Type: System.Reflection.ReflectionTypeLoadException
Source: mscorlib
StackTrace:    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.AggregateCatalog.GetExports(ImportDefinition definition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExports(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
   at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports(ExportProvider provider, ComposablePart part, ImportDefinition definition, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part)
   at System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports)
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionService.SatisfyImportsOnce(ComposablePart part)
   at DevExpress.CodeRush.TestRunner.Core.TestRunnerCompositionService.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
   at DevExpress.CodeRush.TestRunner.Executor45.DefaultTestFrameworkExecutorProvider.GetTestFrameworkExecutor(String runnerAssembly)
Message: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
Source:
StackTrace:
Message: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
Source:
StackTrace:

────────────────────────────────────────────────────────────────────────────────────────────────────

Summary: Passed: 0, Failed: 0, Ignored: 0
Duration: 4.97 seconds
<<<<

Comments (3)
DevExpress Support Team 6 years ago

    Hi Olivier,

    Thank you for pointing out the problem.
    This is a known issue. The Test Runner API in Visual Studio 2019 has been changed and we planned to support the Code Coverage feature in our future releases.
    We will inform you when this feature is implemented.

    O O
    Olivier Jacot-Descombes 6 years ago

      Hi Andrew,

      Thank you for answering my issue promptly. Fortunately I have still VS 2017 installed.

      DevExpress Support Team 6 years ago

        I'm glad that you can use a workaround. We will try to support this functionality as quickly as possible.

        Answers approved by DevExpress Support

        created 6 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          created 6 years ago (modified 6 years ago)

          Hi Olivier,

          We've added the Code Coverage support for MS tests in Visual Studio 2019.
          It is available in the last product version (v 19.1.3).

            Comments (2)
            JH JH
            Jonathan_Halper 6 years ago

              Does CodeRush support code coverage for MSTest v1 under Visual Studio 2019, and if so what are requirements/dependencies to get it running (have tried installing Nuget packages for MsTest.TestFramework and MsTest.TestAdapter but still saw errors and cannot spend much more time investigating right now)?

              Both CodeRush and built-in Visual Studio test runners are working fine just for running tests (without coverage).  But when I run w/ coverage get the error below (this is w/o additional Nuget packages installed).

              Am using:
              Visual Studio Professional 2019
              CodeRush 19.1.4

              Thanks!

              -------------------
              2019.06.03 18:47:13.9076 Information: executor.Start
              2019.06.03 18:47:16.1616 Information: Running tests for Jha.Bsl.Wire.Treasury.Business.Test

              2019.06.03 18:47:16.1676 Error: Message: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
              2019.06.03 18:47:16.1686 Error: Type: System.IO.FileNotFoundException
              2019.06.03 18:47:16.1826 Error: Source: DevExpress.CodeRush.TestRunner.VSUnitTesting16
              2019.06.03 18:47:16.2126 Error: StackTrace:    at DevExpress.CodeRush.TestRunner.VSUnitTesting16.Executor.LoadTests(IEnumerable`1 sources, MSDiscoveryContext discoveryContext)
                 at DevExpress.CodeRush.TestRunner.VSUnitTesting16.Executor.LoadTests(MSDiscoveryContext discoveryContext)
                 at DevExpress.CodeRush.TestRunner.VSUnitTesting16.Executor.Execute(TestFilterBase filter, String solutionDirectory, String lastRunSettingsFilePath)
              2019.06.03 18:47:16.2226 Information: executor exited

              DevExpress Support Team 6 years ago

                HI Jonathan,

                Thank you for contacting us.
                In order to process your question more effectively I've created a separate ticket on your behalf (T746846: CodeRush does not support codecoverage for MSTest v1 under Visual Studio 2019).
                It has been placed in our processing queue and will be answered shortly.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.