Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native Test Explorer

So in 1.59 of vscode "Native support for running tests in VS Code with built-in Test Explorer." was added (https://code.visualstudio.com/updates/v1_59).

My question is, how on earth do I use it? I can find tonnes of resources on how to do it with 3rd party extensions, and in fact in the release notes linked above it namechecks the "Test Explorer UI" (https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer). However that says it is now depreciated due to the aforementioned native implementation. Even then if I install it, I get an icon but no tests underneath. If I follow what little docs I have in those release notes "get the native experience by setting testExplorer.useNativeTesting to true" the icon disappears and I'm back to square one.

Maybe its an expectation vs reality thing, I'm using .net-core, and if I setup a project like so:

dotnet new sln
dotnet new classlib --name MyCode
dotnet new xunit --name MyCode.Tests
dotnet sln add MyCode MyCode.Tests

And open it in VSCode, other than installing the C# extension. What else could it possibly need?

Please note, I know I can install yet another extension (.NET Core Test Explorer - Jun Han) but this seems to totally circumvent the native explorer.

Thanks in Advance.

like image 682
user1832215 Avatar asked Jul 03 '26 18:07

user1832215


1 Answers

I had the same issue. Based on my research and understanding of the docs, the addition to VS Code 1.59+ is apparently ONLY an API that third-party extensions can use.

Last fall we began work on adding native support for running tests in VS Code, and this month the first set of testing-related APIs has been finalized.

There doesn't seem to be any built-in interface, although the docs reference a "built-in Test Explorer" which has made it very confusing. "Test Explorer" is actually the third-party extension. There is apparently no native interface.

Based on this reddit thread, I installed MSTest V2 as a NuGet package (dotnet add package MSTest.TestFramework) and then Jun Han's extension for the test interface. I think otherwise you'd have to use the dotnet test command in the CLI interface.

I wish the MS docs would clarify what they mean by built-in test explorer. I spent half my morning on this!

like image 83
lchras Avatar answered Jul 06 '26 08:07

lchras



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!