MSTest 3.0.1 is broken when using deployment items
See original GitHub issueDescribe the bug
Found while verifying https://github.com/microsoft/testfx/issues/1437.
Steps To Reproduce
- Create UnitTest project in Visual Studio 2022.
- Make sure target framework is .NET Framework 4.8.
- Add .runsettings file.
- Add a deployment item.
- Build and execute unit tests using vstest.console.exe:
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" TestProject1\bin\Debug\net48\TestProject1.dll /Settings:"TestProject1\local.runsettings" /TestAdapterPath:TestProject1\bin\Debug\net48
Expected behavior
Tests execute.
Actual behavior
Tests do not execute.
Additional context
See attached sample project TestProject1.zip.
Tests output:
An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load file or assembly 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack trace:
Server stack trace:
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AssemblyUtility.GetFullPathToDependentAssemblies(String assemblyPath, String configFile, IList`1& warnings)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.AddDependencies(String testSource, String configFile, IList`1 deploymentItems, IList`1 warnings)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.AddDependenciesOfDeploymentItem(String deploymentItemFile, IList`1 filesToDeploy, IList`1 warnings)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtilityBase.Deploy(IList`1 deploymentItems, String testSource, String deploymentDirectory, String resultsDirectory)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtilityBase.Deploy(String source, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, IList`1 deploymentItems, TestRunDirectories runDirectories)
at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestDeployment.Deploy(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken cancellationToken)
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.InvokeExecutor(LazyExtension`2 executor, Tuple`2 executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.<>c__DisplayClass46_0.<RunTestInternalWithExecutors>b__0()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.<>c__DisplayClass0_0.<Run>b__0()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.Run(Action action, PlatformApartmentState apartmentState, Boolean waitForCompletion)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.TryToRunInStaThread(Action action, Boolean waitForCompletion)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)
Issue Analytics
- State:
- Created 9 months ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
c# - DeploymentItem not deploying files
I am using MS unit testing framework for testing my C# library. I have to open a file which I'm deploying using DeploymentItem...
Read more >Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects ......
Read more >MSTest
You can access the MsTest TestContext instance in your step definition or hook classes by constructor injection: using Microsoft.VisualStudio.TestTools.
Read more >Update to MSTestV2 - Visual Studio (Windows)
In this article ... You can upgrade your test project by retargeting the MSTest version referenced in your .csproj from the MSTestV1 to...
Read more >Embracing Continuous Delivery with Azure Pipelines
In this lab, you will learn about the release management features available in Azure Pipelines that automate the deployment of applications.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Evangelink, it worked. Please, release 3.0.2 as soon as possible. Thank you.
I have this same issue in my Azure Pipelines, using vstest@2, no direct mstest reference. It’s coming from MSTestAdapter:
MSTestAdapter failed to discover tests in class
I’m able to make the error stop by using the runsettings disablement of AppDomain, but the tests need the AppDomain, so we need another option.
Is it possible to make the vstest@2 task use the new version (or the old version)?
This is the task I’m referring to:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/vstest-v2?view=azure-pipelines