formulahendry / vscode-dotnet-test-explorer

.NET Core Test Explorer for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=formulahendry.dotnet-test-explorer
MIT License
202 stars 95 forks source link

Discovering Tests process does NOT populate the .NET Test Explorer Pane #346

Open aIex-souza opened 2 years ago

aIex-souza commented 2 years ago

Project Path issue...

I've read too many posts about this issue and can't find a solution for the discovery process to work... But, still, on the .Net Test Explorer (v0.7.7) Pane on VSCode Version: 1.62.3 (user setup), the tests can only be found if I click on the "Run All Tests" button, (which is not what I need.) and it keeps giving me the "No tests found", even after tests are discovered by clicking on "Run All Tests" I can't run a specific test...

When I open VSCode and look at the .Net Test Explorer output, it reads like this: Starting extension Finding projects for pattern c:/[path to my project]/*/.Tests.csproj Found 1 matches for pattern in folder c:[path to my project] Evaluating match c:/[path to my project]/XYX.Tests/XYZ.Tests.csproj Adding directory c:/[path to my project]/XYZ.Tests Executing dotnet test -t -v=q in c:/[path to my project]/XYZ.Tests

Manually executing the command "dotnet test -t -v=n [full test project path]" it tells me that all X tests were found...

These are the package references on my main/test .csproj files... Microsoft.NET.Test.Sdk - Version=17.0.0 NUnit - Version=3.13.2 NUnit.Console - Version=3.11.1 NUnit3Testadapter - Version=4.1.0 TestCentric.Metadata - Version=1.7.1

Sorry if I missed the post that fixes this issue... can someone give me some other places to look? IDK what else can be looked at :(

aIex-souza commented 2 years ago

Nevermind... It seems I have NOT read through all the posts... Issue is fixed by adding "-- NUnit.DisplayName=FullName" on Dotnet-test-explorer: Test Arguments (Extension Settings), but...

Now with the Tests Discovery resolved, I don't get the updates "check mark" or "X" when tests Succeed or Fail... and can't run individual tests, if I do so, the "?" icon appears and no errors are displayed on the log...

vaughanbrittonsage commented 2 years ago

I also have this same issue, any assistance would be appreciated.

vaughanbrittonsage commented 2 years ago

Some additional information on this, if I take the command generated in the output logs and try running the command:

dotnet test -- "NUnit.DisplayName=FullName" --no-build --logger "trx;LogFileName={path to my tmp test results dir}/test-explorer-hM1lUS/0.trx" --filter "FullyQualifiedName~{Namespace of my class}"

I get the following error:

One or more runsettings provided contain invalid token
vaughanbrittonsage commented 2 years ago

so it appears that the issue is caused by the test execution failing to run

thegrahamking commented 1 year ago

Issue is fixed by adding "-- NUnit.DisplayName=FullName" on Dotnet-test-explorer: Test Arguments (Extension Settings), but... Now with the Tests Discovery resolved, I don't get the updates "check mark" or "X" when tests Succeed or Fail... and can't run individual tests, if I do so, the "?" icon appears and no errors are displayed on the log...

I'd had this same experience. I've been able to determine the cause.

With Dotnet-test-explorer: Test Arguments (Extension Settings) set to "-- NUnit.DisplayName=FullName" the following command is executed (when running a single test): dotnet test -- NUnit.DisplayName=FullName --no-build --logger "trx;LogFileName=C:\Users\{user}\AppData\Local\Temp\test-explorer-YWo0Ky\0.trx" --filter "FullyQualifiedName=MyAssembly.Tests.MyNamespace.MyClass.Test.Method"

When you run this command manually (on the command line) all of the tests in the found assemblies run, not just the test selected/specified and no log file is generated

If you run dotnet test --no-build --logger "trx;LogFileName=C:\Users\{user}\AppData\Local\Temp\test-explorer-YWo0Ky\0.trx" --filter "FullyQualifiedName=MyAssembly.Tests.MyNamespace.MyClass.Test.Method" -- NUnit.DisplayName=FullName then the single test is run and the log file is generated.

It appears that the problem is the extension is adding the additional arguments to the beginning when they should be at the end. This is in the docs https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test

RunSettings arguments Inline RunSettings are passed as the last arguments on the command line after "-- " (note the space after --)