microsoft / vstest

Visual Studio Test Platform is the runner and engine that powers test explorer and vstest.console.
MIT License
869 stars 316 forks source link

System.InvalidOperationException and System.Collections.Generic.KeyNotFoundException errors when running tests #4208

Closed liamfl closed 11 months ago

liamfl commented 1 year ago

Description

I am running unit tests on a 2 c# test projects using the lates version of Visual Studio Community 2022

The 2 test project are named EngineTests and ServerCodeTests.

While the test projects compile correctly, I regularly get a series of error messages in the Output / Tests window when running unit tests:

System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown System.Collections.Generic.KeyNotFoundException: The given key 'C:\Users\liamf\Source\Repos\TradingReplay\ServerCodeTests\bin\Debug\net6.0\ServerCodeTests.dll' was not present in the dictionary. An exception occurred while test discoverer 'MSTestDiscoverer' was loading tests. Exception: Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.StringEx' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. No test is available in C:\Users\liamf\Source\Repos\TradingReplay\ServerCodeTests\bin\Debug\net6.0\ServerCodeTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Steps to reproduce

Running any test from Test Explorer.

Reloading Visual Studio allows you to do 2-3 test runs before the issue arises again.

Diagnostic logs

ErrorLog.text attached

Environment

Windows 11 10.0.22621 Build 22621 Visual Studiio Community v17.4.3

Nuget packages: MSTest.TesAdapter v3 MSTest.TestFramework v3 Microsoft.NET.Test.SDK v17.4 ErrorLog.txt

Evangelink commented 1 year ago

Relates to https://developercommunity.visualstudio.com/t/Unit-test-startup-fails-with-an-exceptio/10226576

Evangelink commented 1 year ago

This is currently being investigated, we will post back when we have more info.

jeremyregnerus commented 1 year ago

I have this same issue and have found this to happen whenever you delete or rename a test method.

robin-kilpatrick commented 1 year ago

I have the same issue - run the same test twice and then I can't run it a third time until I restart vs2022 community

primalspacesystems commented 1 year ago

I'm having the same problem - Visual Studio Community 17.4.3 - but for a mixture of C++ and C# tests.

Most of the time, a machine reboot seems to make the issue go away for a while - this is less than ideal :/

(Debug spew after about info)

Cheers John

Microsoft Visual Studio Community 2022 Version 17.4.3 VisualStudio.17.Release/17.4.3+33205.214 Microsoft .NET Framework Version 4.8.04161

Installed Version: Community

Visual C++ 2022 00482-90000-00000-AA725 Microsoft Visual C++ 2022

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 17.4.326.54890 ASP.NET and Web Tools

ASP.NET Web Frameworks and Tools 2012 17.4.326.54890 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 17.4.326.54890 Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.4.326.54890 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CodeLensOopProviderCommands Extension 1.0 CodeLensOopProviderCommands Visual Studio Extension Detailed Info

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 17.0.22263.6 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Linux Core Dump Debugging 1.0.9.33020 Enables debugging of Linux core dumps.

Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

P4VS - Helix Plugin for Visual Studio 2021.2.235.1465 P4VS is the Helix Plugin for Microsoft Visual Studio. P4VS provides developers working within Visual Studio access to Helix version control features, including check in/check out, view file history, and more.

Python - Django support 17.0.22263.6 Provides templates and integration for the Django web framework.

Python - Profiling support 17.0.22263.6 Profiling support for Python projects.

Python with Pylance 17.0.22263.6 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0 Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62207.28050 Microsoft SQL Server Data Tools

Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Linux Development 1.0.9.33020 Visual C++ for Linux Development

Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.ToLocalTestResultRecord(TestResultRecord testResult) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.AddTestResultRecords(IEnumerable1 testResultRecords) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestResultRecords(IEnumerable1 testResults) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunUpdate(IEnumerable1 testResults, IEnumerable1 activeTests) at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.TestResponseHandler.<>c__DisplayClass16_0.<HandleTestRunStatsChangeAsync>b__0() at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow) System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext() System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin) at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsNotRunningAndNotPending() at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsNotRunningAndNotPending(TestCaseOriginKind originKind) at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind) at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.EndTestRun() at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunCompleted() at Microsoft.VisualStudio.TestWindow.Utilities.EventPumpExtensions.<>c__DisplayClass0_0.<EnqueueAsync>b__0() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__111.MoveNext()

gigimignon commented 1 year ago

I have same issue on Microsoft Visual Studio Professional 2022 (64 bits) - Current Version 17.4.3

It seems that explorer fail to refresh tests. Some times, one test with DataRow appairs two times (one time without DataRow and one time with all DataRow) Some times, rename a test not refresh test explorer.

stilldesign commented 1 year ago

I'm having the same issue when renaming a test method. New test methods are detected and run correctly. When loading a project after the test window has initialized, then newly discovered tests will just fail to run. Everything worked fine in 2.2.10. I know there have been a lot of changes between this and v3. Hope it can be resolved :) For now, simply restarting Visual Studio gets everything working again.

MichelZ commented 1 year ago

3.0.1 has been released, have you tried those yet?

Evangelink commented 1 year ago

Hey there, we are still investigating the issue but at the moment it doesn't seem that the issue is caused directly by MSTest (it's possible this is linked to an updated dependency to Test Platform - we are looking into it).

peterwald commented 1 year ago

This looks to be an issue with the Test Explorer in Visual Studio. The problem is triggered by some new functionality in MSTest 3, however that is not where the problem lies. We are working on a fix currently and will let you know when we know more.

gigimignon commented 1 year ago

3.0.1 has been released, have you tried those yet?

Ues, I have the last version 3.0.1

gurkantuna commented 1 year ago

Hey there, we are still investigating the issue but at the moment it doesn't seem that the issue is caused directly by MSTest (it's possible this is linked to an updated dependency to Test Platform - we are looking into it).

Hey @Evangelink, I definitely think it's an issue caused directly by MSTest because it still throws exception even though I removed all other dependencies and other TestMethods in my test project.

Animation

Evangelink commented 1 year ago

Hi @g-u-r-k-a-n,

Yes issue is caused by MSTest but what I meant and that @peterwald explained is that we have used a new functionality for Test Explorer, through the use of Test Platform Object Model that seems to be causing the issue. So yes it's because you are using MSTest v3 but it's not linked to something we implement but rather either by Test Explorer change of behaviour or by some change on the object model implementation.

Nonetheless, we are investigating the issue and will provide a fix as soon as we can.

hjrb commented 1 year ago

Hi, having the same issue with VS 2022 Enterprise version 17.4.3 For me it works on the same machine (same project) with VS Enterprise Preview Version 17.5.0 Preview 2.0 But after a while it also stops working as described above....

Here is the VS 2022 Preview version info. Microsoft Visual Studio Enterprise 2022 Version 17.5.0 Preview 2.0 VisualStudio.17.Preview/17.5.0-pre.2.0+33209.295 Microsoft .NET Framework Version 4.8.04084

Installed Version: Enterprise

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 17.5.194.32986 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.5.194.32986 Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.5.194.32986 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

Bundler & Minifier 2.9.3 Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.

C# Tools 4.5.0-2.22580.13+ea0b6351c129c7decd9bf76f4388239509e28e0d C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Clean Solution 1.4.35 Cleans up the solution for the next time you open it. Closes open documents and collapses folders automatically when a solution is being closed.

CleanBinAndObjCommand Extension 1.2.58 CleanBinAndObjCommand Visual Studio Extension Detailed Info

Clear MEF Component Cache 1.4 Clears the Visual Studio MEF component cache to fix issues with cache corruption.

Code alignment 15.1.118.0 Code alignment helps you present your code beautifully, enhancing clarity and readability.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 17.0.22318.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

CreateUnitTestBoilerplateCommand Extension 1.0 CreateUnitTestBoilerplateCommand Visual Studio Extension Detailed Info

Entity Framework Core Power Tools 2.5 Adds useful design-time EF Core DbContext features to the Visual Studio Solution Explorer context menu.

Extensibility Message Bus 1.4.1 (main@2ee106a) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

File Differ 3.0.43 The easiest way to diff two files directly in Solution Explorer

File Icons 2.7 Adds icons for files that are not recognized by Solution Explorer

IndentRainbowPackage Extension 1.0 IndentRainbowPackage Visual Studio Extension Detailed Info

Markdown Editor v2 2.0.130 A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Menu Extension 1.0 Menu Visual Studio Extension Detailed Info

Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query

Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.5.2 (d15e47f) Support for debugging Mono processes with Visual Studio.

Node.js Tools 1.5.41130.1 Commit Hash:8e2bd0c47a236f67dd4a99f60aacfa306308387c Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 6.5.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

OpenOnGitHub 1.3 Visual Studio Extension for opening files on GitHub.com

Python - Profiling support 17.0.22318.1 Profiling support for Python projects.

Python with Pylance 17.0.22318.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Rainbow Braces 1.0.40 Colorizes matching brace pairs to make it easy to identify them and their scope. Works for curly brackets, parentheses, and square brackets.

Razor (ASP.NET Core) 17.0.0.2255201+5530de5c8323cd1ecacb497bbab5637907d0fc02 Provides languages services for ASP.NET Core Razor.

ResX Resource Manager ResXManager Manage localization of all ResX-based resources in one place. Shows all resources of a solution and lets you edit the strings and their localizations in a well-arranged data grid.

Select Next Occurrence 1.4.182 Selects the next occurrence of the current selection and adds multiple cursors for editing.

SonarLint for Visual Studio 6.9.0.54300 SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code.

SQL Server Data Tools 17.2.31208.0 Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 17.0.11130.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.5.0-2.22580.13+ea0b6351c129c7decd9bf76f4388239509e28e0d Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.5.0-beta.22607.4+f5794982b82d308590542bd1e101162dc4f45a13 Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

Visual Studio Spell Check Everywhere VSSpellCheckEverywhere An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes. https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker VSSpellChecker An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows. https://GitHub.com/EWSoftware/VSSpellChecker

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSColorOutput64 2022.2 Color output for build and debug windows - https://mike-ward.net/vscoloroutput

Word Highlight With Margin Extension 1.0 Highlight all occurrences of a selected word and display carets on the enhanced vertical scrollbar at the right margin.

Xamarin 17.5.0.120 (main@4c08778) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.5.2.64 (remotes/origin/d17-5@627f860876) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.5.3 (3c53880) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.1.99.61 (main/2e10309) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 6dd9def Java.Interop: xamarin/java.interop/main@984711a3 SQLite: xamarin/sqlite/3.40.0@fdc1e34 Xamarin.Android Tools: xamarin/xamarin-android-tools/main@fa3711b

Xamarin.iOS and Xamarin.Mac SDK 16.1.1.27 (933c6c2c9) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

IndigoHealth commented 1 year ago

Ok, this is really weird! I added <Nullable>enable</Nullable> to my library project that contains my custom assert routines (e.g., AssertEx.DictionariesAreEqual(...)), and I corrected the resulting warnings and errors. When I tried running the test cases (in VS 2022 Pro v 17.4.3), the Test Explorer panel behaved weirdly. It didn't display the "I'm working on it" icons for my tests, but it seemed to be telling me that everything passed. And it gave me a bunch of errors under the "Errors" notification at the top-right corner of that panel and in the "Tests" output.

Since I read (above) that some folks have resolved the issue by rebooting, I closed VS and rebooted my computer. And... now the problem has magically disappeared.

Don't know if this helps the investigation at all.

nietras commented 1 year ago

I am consistently hitting this issue too in VS 2022 17.5.0 Preview 2.0 with:

    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
    <PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
    <PackageReference Include="MSTest.TestFramework" Version="3.0.0" />

with .NET SDK 7.0.101 and targetting net7.0. I am not hitting this issue using v2 of MSTest in same VS it seems.

System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsNotRunningAndNotPending()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.EndTestRun()
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunCompleted()
   at Microsoft.VisualStudio.TestWindow.Utilities.EventPumpExtensions.<>c__DisplayClass0_0.<EnqueueAsync>b__1()
   at Microsoft.VisualStudio.TestWindow.Extensibility.TaskCompletionSourceExtensions.RunActionWithCatch[T](TaskCompletionSource`1 taskCompletionSource, Action action)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)

Makes running tests in VS impossible after just a few runs.

lanwin commented 1 year ago

Same problem here. Interestingly the R# Testrunner seems to work.

Restarting VS solves the problem for me. But its annoying.

Evangelink commented 1 year ago

Interestingly the R# Testrunner seems to work.

The error is coming from VS Test Explorer window trying to exploit some new feature enabled in v3 of MSTest. Because this feature is for VS Test Explorer only, it makes sense there is no impact outside of VS.

bollmanncom commented 1 year ago

Same here. Sometimes I can make only one test run before the error occurs.

mm-ryo commented 1 year ago

Same problem. It's only happpend in integration tests. Unit tests are working fine.

Message:  Test method Test.IntegrationTests.**_ReturnsExpectedResultAsync threw exception: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Http.ObjectContent1[[System.Collections.Generic.List1[[**, **, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]'.

Stack Trace:  HttpContent.CopyToAsync(Stream stream, TransportContext context, CancellationToken cancellationToken) <b0>d.MoveNext() --- End of stack trace from previous location --- <gRunRequestAsync|0>d.MoveNext() --- End of stack trace from previous location --- ClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) CookieContainerHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) **_ReturnsExpectedResultAsync() line 192

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.ToLocalTestResultRecord(TestResultRecord testResult) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.AddTestResultRecords(IEnumerable1 testResultRecords) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestResultRecords(IEnumerable1 testResults) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunUpdate(IEnumerable1 testResults, IEnumerable`1 activeTests) at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.TestResponseHandler.<>c__DisplayClass16_0.b__0() at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)

Evangelink commented 1 year ago

@peterwald @ocallesp Can we have some news on the investigation/fix of this issue?

KvnSearle commented 1 year ago

I started seeing this error when I updated my nuget packages.

MSTest.TestAdapter and MSTest.Framework got up graded to version 3.0.2.

I switched them back to version 3.0.0 and the issue went away.

LonelyWolf123 commented 1 year ago

Here's my workaround. Close your solution and close Visual Studio Enterprise, then kill vbcscompiler.exe process. Once restarted, it works ... but I do this 100 times for day. Very big loose of time, in this way Visual Studio is really unusable. Hope it will be fixed soon

peterwald commented 1 year ago

@peterwald @ocallesp Can we have some news on the investigation/fix of this issue?

We hear the feedback and are actively working on a fix. It's a bit of a tricky bug/fix and it is taking some time to validate, but we will have a fix shortly.

LonelyWolf123 commented 1 year ago

I started seeing this error when I updated my nuget packages.

MSTest.TestAdapter and MSTest.Framework got up graded to version 3.0.2.

I switched them back to version 3.0.0 and the issue went away.

Starting from your suggestion, I made this attempt: use default packages when creating a new test project. But it was not enough to go back to version 3.0.0 of Testframework and Testadapter, I had to do it for all the packages used for testing, including fakes. Then clean solution / projects and rebuild. So far the issue has not recurred.

here's the package versions, the same of a new test project created with VS 17.4.3:

Microsoft.NET.Test.Sdk, Version="17.3.2" Microsoft.QualityTools.Testing.Fakes Version="16.11.230815" MSTest.TestAdapter Version="2.2.10" MSTest.TestFramework Version="2.2.10" coverlet.collector Version="3.1.2"

gavinmckay commented 1 year ago

I've temporarily switched to using the VSTest console instead (https://learn.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2022) accessed within VS Enterprise 2022 via:

  1. Tools -> Command Line -> Developer Command Prompt
  2. vstest.console.exe The.Project.dll /Tests:YOUR_TEST_PREFIX

It's certainly not ideal but better than restarting VS and the debug tools multiple times. Not sure if this will end up with the same issue but reading the above I suspect not as it doesn't use the VS Test dialog at all.

Edit: and I can also still debug the failing unit tests as well via Visual Studio, so it's clunky but I can (a) work out what is failing using the Console and (b) debug to find out why using Visual Studio

abatishchev commented 1 year ago

Exceptions:

System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsStale()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.StartTestRun(IEnumerable`1 containers, IEnumerable`1 requestedTestCasesToRun, Boolean isHotReloadRun)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.StartTestRun(IEnumerable`1 containers, IEnumerable`1 requestedTestCasesToRun, Boolean isHotReloadedRun, Int32 totalIterations)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.StartTestRun(ICollection`1 requests, Int32 totalIterations)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
MSTest Executor: Test Parallelization enabled for D:\Projects\src\Service\GatewayService.Tests\bin\x64\Debug\net462\GatewayService.Tests.dll (Workers: 8, Scope: MethodLevel).
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.ToLocalTestResultRecord(TestResultRecord testResult)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.AddTestResultRecords(IEnumerable`1 testResultRecords)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestResultRecords(IEnumerable`1 testResults)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunUpdate(IEnumerable`1 testResults, IEnumerable`1 activeTests)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.TestResponseHandler.<>c__DisplayClass16_0.<HandleTestRunStatsChangeAsync>b__0()
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext()
System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsNotRunningAndNotPending()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.EndTestRun()
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunCompleted()
   at Microsoft.VisualStudio.TestWindow.Utilities.EventPumpExtensions.<>c__DisplayClass0_0.<EnqueueAsync>b__0()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__11`1.MoveNext()

Packages:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" version="3.0.2" />

IDE:

Microsoft Visual Studio Enterprise 2022
Version 17.4.3
VisualStudio.17.Release/17.4.3+33205.214
Microsoft .NET Framework
Version 4.8.04084
DavidBerg-MSFT commented 1 year ago

FYI. I just upgraded all my NuGet packages yesterday (MSTest.TestAdapter and TestFramework went from version 2.1.2 to 3.0.2) and now I'm encountering similar issues (I can't run any unit tests in Test Explorer). I tried restarting VS and rolling back TestAdapter and TestFramework to version 2.2.8, but so far that's not worked.

I do a Test|Run All Tests and it builds, then just comes back and says "ready" without appearing to run any of the tests. I was able to Debug a test and it ran in the debugger, but at the end it still said it didn't run.

Output window:

Here's the relevant portion of the Output window:

========== Starting test discovery ========== Multiple versions of same extension found. Selecting the highest version. Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter : 14.0.7923.2 An exception occurred while test discoverer 'MSTestDiscoverer' was loading tests. Exception: Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.StringEx' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. No test is available in C:\one\Azure-Core-Performance\src\PowerUI\PowerUI.Test\bin\x64\Debug\PowerUI.Test.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. No test is available in C:\one\Azure-Core-Performance\src\PowerUI\PowerUI\bin\x64\Debug\PowerUI.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. No test is available in C:\one\Azure-Core-Performance\src\PowerUI\PowerUI.InteractiveTest\bin\x64\Debug\PowerUI.InteractiveTest.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. ========== Test discovery finished: 0 Tests found in 2.9 sec ========== ========== Starting test run ========== ========== Test run finished: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in < 1 ms ========== ========== Starting test discovery ========== ========== Test discovery skipped: All test containers are up to date ==========

Why does this refer to MSTest.TestAdapter : 14.0.7923.2 while NuGet refers to version 2.2.8 / 3.0.2?

vstest.console

Just tried with vstest.console, I get the same error, but with a full call stack:

An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.StringEx' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestSettings.PopulateSettings(IDiscoveryContext context)
   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)
peterwald commented 1 year ago

This issue has now been fixed. It will be available in the next preview release of VS 17.5. It should also be included in the next 17.4 update as well when that becomes available.

KotM commented 1 year ago

17.5 Preview 2. Still reproduced.

Just inserted new test method by tesm snippet, wrote few lines of code. In test explorer other test methods from that class suddenly disappear, only newly created method was remained. Attempt to run it displays the same exception, VS restarting helps.

Project is clean NET6. Originally it was NET6+Framework4.8, the same issue observed. Now it was migrated to NET6, VS was updated to recommended above version, nothing changed. :(

Intermittent.

KotM commented 1 year ago
========== Starting test run ==========
System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsStale()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsStale(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.StartTestRun(IEnumerable`1 containers, IEnumerable`1 requestedTestCasesToRun, Boolean isHotReloadRun)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.StartTestRun(IEnumerable`1 containers, IEnumerable`1 requestedTestCasesToRun, Boolean isHotReloadedRun, Int32 totalIterations)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.StartTestRun(ICollection`1 requests, Int32 totalIterations)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
System.Collections.Generic.KeyNotFoundException: The given key 'D:\dev\TTA_rating_bot\TTRatingBot\RatingCalculators.Tests\bin\Debug\net6.0\RatingCalculators.Tests.dll' was not present in the dictionary.
   at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.ToTestResultRecord(TestResultRecord testResult, IImmutableDictionary`2 containerLookup, TestStore store, Int32 testRunIndex, Boolean isHotReloadedRun, Int32 currentIteration)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.ToLocalTestResultRecord(TestResultRecord testResult)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.AddTestResultRecords(IEnumerable`1 testResultRecords)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestResultRecords(IEnumerable`1 testResults)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunUpdate(IEnumerable`1 testResults, IEnumerable`1 activeTests)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.TestResponseHandler.<>c__DisplayClass16_0.<HandleTestRunStatsChangeAsync>b__0()
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsNotRunningAndNotPending()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.EndTestRun()
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunCompleted()
   at Microsoft.VisualStudio.TestWindow.Utilities.EventPumpExtensions.<>c__DisplayClass0_0.<EnqueueAsync>b__1()
   at Microsoft.VisualStudio.TestWindow.Extensibility.TaskCompletionSourceExtensions.RunActionWithCatch[T](TaskCompletionSource`1 taskCompletionSource, Action action)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__11`1.MoveNext()
System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin)
   at Microsoft.VisualStudio.TestStorage.MergedTestGroup.MarkAsNotRunningAndNotPending()
   at Microsoft.VisualStudio.TestStorage.MergedTestIndex.MarkAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestStorage.TestStore.MarkTestsAsNotRunningAndNotPending(TestCaseOriginKind originKind)
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.EndTestRun()
   at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestRunCompleted()
   at Microsoft.VisualStudio.TestWindow.Utilities.EventPumpExtensions.<>c__DisplayClass0_0.<EnqueueAsync>b__1()
   at Microsoft.VisualStudio.TestWindow.Extensibility.TaskCompletionSourceExtensions.RunActionWithCatch[T](TaskCompletionSource`1 taskCompletionSource, Action action)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Host.TestPlatformProvider.<RunTestsAsync>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__11`1.MoveNext()
peterwald commented 1 year ago

17.5 Preview 2. Still reproduced.

@KotM Sorry I should have been more clear. The releases I was referring to have not shipped yet. They will likely be 17.5 Preview 3, and 17.4.5.

scudderk commented 1 year ago

@peterwald is there a place where I can see the ETA for VS 2022 releases?

peterwald commented 1 year ago

@peterwald is there a place where I can see the ETA for VS 2022 releases?

I don't believe that information is publicly available, but the release is imminent.

stilldesign commented 1 year ago

I'm running MSTest 3.0.2 and just updated to VS Version 17.5.0 Preview 3.0 and the issue has been resolved :) I can rename test methods and they are detected and run correctly once again

stormbee commented 1 year ago

I have the same issue - run the same test twice and then I can't run it a third time until I restart vs2022 community

Reopen solution also remove error

bvbellomo commented 1 year ago

same issue

Dmytro-Hryshyn-89 commented 1 year ago

Same issue, tests not running after rename. Can run unit tests after Visual studio 2022 restart.

Resharper test explorer doesn't have this issue, have to use it instead. 😒

KieranDevvs commented 1 year ago

Same issue here. Remove or rename a project and then re-run your tests and you get errors until you reboot VS2022.

KieranDevvs commented 1 year ago

@Evangelink can we get this re-opened?

peterwald commented 1 year ago

@bvbellomo @Dmytro-Hryshyn-89 @KieranDevvs Can you confirm what version of VS you are running? The 17.4.5 version of VS has not shipped yet. So, unless you have upgraded to a preview version of VS, then it is expected that you would have the same issue.

KieranDevvs commented 1 year ago

@bvbellomo @Dmytro-Hryshyn-89 @KieranDevvs Can you confirm what version of VS you are running? The 17.4.5 version of VS has not shipped yet. So, unless you have upgraded to a preview version of VS, then it is expected that you would have the same issue.

If the fix hasn't shipped yet, then the issue isn't solved thus the ticket should remain open.

peterwald commented 1 year ago

If the fix hasn't shipped yet, then the issue isn't solved thus the ticket should remain open.

There are multiple versions that this fix was shipped in. The 17.5 previews have been shipped for a few weeks now and we've had responses above confirming the fix. As I mentioned earlier, it takes a much more involved process to ship servicing updates to earlier releases and thus there will be a delay until the 17.4 line receives this update.

StephanMoeller commented 1 year ago

I imagine the time loss around the world caused by this bug alone. Do you have any idea when the fix will be part of something non-preview?

Dmytro-Hryshyn-89 commented 1 year ago

Hi @peterwald sorry for delay. I am running Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.4.4

peterwald commented 1 year ago

The 17.4.5 release is now publicly available including this fix.

DrewM-Hax0r commented 1 year ago

Thanks, 17.4.5 fixed this issue for me.

gusarov commented 1 year ago

Any intermediate solution for this? I have this from commandline, without VS...

An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load type 'Microsoft.VisualStudio.TestTools.UnitTesting.StringEx' from assembly 'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestSettings.PopulateSettings(IDiscoveryContext context)
TomKuhn commented 1 year ago

This is not fixed in Visual Studio 2022 Enterprise V17.5.4

I am using NUNIT, not MSTest

System.InvalidOperationException: TestsForOrigin: Unknown TestCaseRecord.Origin value Unknown at Microsoft.VisualStudio.TestStorage.MergedTestGroup.TestsForOrigin(TestCaseOrigin origin) at Microsoft.VisualStudio.TestStorage.MergedTestGroup.get_AllTestCases() at Microsoft.VisualStudio.TestStorage.MergedTestIndex.AddTestCase(TestCaseRecord testCase, Boolean& isMutationVisibleInHierarchy, IEnumerable1& testsToRemove) at Microsoft.VisualStudio.TestStorage.TestStoreIndexSet.AddToIndexSet(TestBaseRecord record, Boolean isLoadingFromCache) at Microsoft.VisualStudio.TestStorage.TestStore.Add(TestBaseRecord record, Boolean onlyAddIfNew) at Microsoft.VisualStudio.TestWindow.Host.TestRunSession.AddTestCases(ICollection1 testCaseRecords) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.AddRemoteTestCaseRecords(IEnumerable1 testCases) at Microsoft.VisualStudio.TestWindow.Host.VsTestRunSession.OnTestsDiscovered(IEnumerable1 testsDiscovered) at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.CallInternalWithLogging(IInternalLogger log, Action action, Boolean shouldThrow)

Evangelink commented 1 year ago

@peterwald I will let you handle this.