question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.NET Core 3.1 KeyNotFoundException, Unable to find UniqueTest VSTestAdapter

See original GitHub issue
========== Discovery finished: 120 tests found (0:00:01.4609728) ==========
System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter,D:\path_to_file\bin\Debug\netcoreapp3.1\MyFile.Tests.dll,MyFile.Tests.Services.ClassNameTests.ExtractUnitNumber_Success,:0a4559b4-6ae5-7f70-0224-19d70ce93653
   at Microsoft.VisualStudio.TestStorage.TestStoreHierarchyNode.LookupUniqueTest(MergedTestIndex index)
   at Microsoft.VisualStudio.TestStorage.TestStoreHierarchyIndex.<>c__DisplayClass41_0.<GetTestContainersForNodes>b__0(TestStoreHierarchyNode ct)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Microsoft.VisualStudio.TestStorage.TestStore.UpdateContainerConfigs(IDictionary`2 allContainerConfigs, IEnumerable`1 containers, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestStorage.TestStore.GetTestContainersForNodes(Int32 viewId, IEnumerable`1 nodeIds, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestWindow.Host.TestWindowStoreService.<>c__DisplayClass34_0.<GetTestSourcesAsync>b__0()
   at Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions.<CallWithCatchAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.Controller.TestContainerConfigurationQueryByTestsBase.<QueryTestContainerConfigurationsAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.TestContainerConfigurationQuery.<GetTestContainerConfigurationsAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.TestRunConfiguration.<UpdateAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RunOperation.<RunTestsAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<<Execute>b__37_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions.<CallWithCatchAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
  • NUnit: 3.12.0
  • NUnit3TestAdapter: 3.16.0
  • Framework: netcoreapp3.1

I was on .NET Core 2.2 before and it worked fine. Is there anything preventing 3.1 from running these tests in VS2019 ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
IvanStoychevcommented, Jan 29, 2020

@OsirisTerje , ah, sorry, now I realize the package information, relating to my local folders, is in the .csproj file.

Indeed I have xUnit but the error I got was the exact same and I couldn’t find anything on the 'Net about it, so I thought to post here. 😃

EDIT: In case anyone with xUnit and the same exception stumbles upon this, let it be known that in my case installing this nUnit adapter fixed the xUnit problem (even after uninstalling the nUnit adapter).
¯\_(ツ)_/¯

1reaction
OsirisTerjecommented, Jan 6, 2020

The exception is fixed in the upcoming 16.5 Preview -2, which should be out real soon now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to find UniqueTest VSTestAdapter
This causes the following exception to be thrown with no tests run. System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter,C:\ ...
Read more >
xUnit tests suddenly throwing exception System. ...
xUnit tests suddenly throwing exception System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter.
Read more >
Visual Studio Testing - Microsoft Q&A
System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter I needed assistance on this error. When I run Test Automation.
Read more >
VS2022 V17.4.5 problem
KeyNotFoundException : Unable to find UniqueTest VSTestAdapter,C:\ADO\Tests\bin\Debug\Tests.dll,Tests.AutomatedEmails.
Read more >
How To Resolve Issue Of Test Project Not Running The ...
Introduction. I was upgrading the .NET Core 3.1 project to .NET 6 and faced issues running test cases in my test projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found