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

Running induvidual tests doesn't work - Could not find a matching test directory for test #355

Open PavelCibulka opened 2 years ago

PavelCibulka commented 2 years ago

Hello, I have Unity project with NUnit tests. If I open Testing tab, there are not tests visible: image

console output: Starting extension Finding projects for pattern /home/pavel/NetBeansProjects/imperium/Assets/Tests/*/Tests.*.csproj Found 2 matches for pattern in folder /home/pavel/NetBeansProjects/imperium Evaluating match /home/pavel/NetBeansProjects/imperium/Assets/Tests/core/Tests.Core.csproj Adding directory /home/pavel/NetBeansProjects/imperium/Assets/Tests/core Evaluating match /home/pavel/NetBeansProjects/imperium/Assets/Tests/def/Tests.Def.csproj Adding directory /home/pavel/NetBeansProjects/imperium/Assets/Tests/def Executing dotnet test -t -v=q in /home/pavel/NetBeansProjects/imperium/Assets/Tests/core

If I click run all button, all tests runs just fine: image

console output: ` Executing dotnet build in /home/pavel/NetBeansProjects/imperium/Assets/Tests/core Executing dotnet test --no-build --logger "trx;LogFileName=/tmp/test-explorer-apqaEd/0.trx" in /home/pavel/NetBeansProjects/imperium/Assets/Tests/core Process 11783 started Test run for /home/pavel/NetBeansProjects/imperium/Temp/tests.core/Bin/Debug/net6.0/tests.core.dll (.NETCoreApp,Version=v6.0) Microsoft (R) Test Execution Command Line Tool Version 17.1.0 Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait... A total of 1 test files matched the specified pattern. Results File: /tmp/test-explorer-apqaEd/0.trx

Passed! - Failed: 0, Passed: 12, Skipped: 0, Total: 12, Duration: 727 ms - /home/pavel/NetBeansProjects/imperium/Temp/tests.core/Bin/Debug/net6.0/tests.core.dll (net6.0)

Process 11783 finished Executing dotnet build in /home/pavel/NetBeansProjects/imperium/Assets/Tests/def Executing dotnet test --no-build --logger "trx;LogFileName=/tmp/test-explorer-apqaEd/1.trx" in /home/pavel/NetBeansProjects/imperium/Assets/Tests/def Process 11882 started Test run for /home/pavel/NetBeansProjects/imperium/Temp/tests.def/Bin/Debug/net6.0/tests.def.dll (.NETCoreApp,Version=v6.0) Microsoft (R) Test Execution Command Line Tool Version 17.1.0 Copyright (c) Microsoft Corporation. All rights reserved.

Starting test execution, please wait... A total of 1 test files matched the specified pattern. Results File: /tmp/test-explorer-apqaEd/1.trx

Passed! - Failed: 0, Passed: 30, Skipped: 0, Total: 30, Duration: 354 ms - /home/pavel/NetBeansProjects/imperium/Temp/tests.def/Bin/Debug/net6.0/tests.def.dll (net6.0)

Process 11882 finished `

If I run individuals test or test group, I will get error: [WARNING] Could not find a matching test directory for test imperium.tests.core.ConfigLoaderTest

I've tried to find more info what does this mean. How and where I can set "matching" test directory. But I've found nothing.

I don't know if problem is in project settings, VSCode settings, test explorer settings, vsocde bug, test explorer bug, dotnet bug or something else.

mpelley commented 2 years ago

I am having the same problem trying to run an individual test from this Test Explorer. I am also not able to run a test by clicking the "Debug Test" link shown in the source code. I am able to run a test by typing dotnet test --filter="Name~MyTest".

kcaswick commented 2 years ago

I'm encountering a very similar issue, but when running individual tests it fails finding things during build rather than run. It seems to randomly come and go.

----- Running test method "REDACTED.WebAPI.Controllers.UnitTests.REDACTEDControllerTests.GetTest_REDACTED_Succeeds" -----

Microsoft (R) Build Engine version 17.1.0+ae57d105c for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  REDACTED.Core -> /usr/src/app/REDACTED.Core/bin/Debug/net6.0/REDACTED.Core.dll
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception:  [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/usr/src/app/REDACTED.Infrastructure/bin/Debug/net6.0/ref/REDACTED.Infrastructure.dll'. [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :    at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
/usr/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(4650,5): error :  [/usr/src/app/REDACTED.Infrastructure/REDACTED.Infrastructure.csproj]
  REDACTED.Core.UnitTests -> /usr/src/app/REDACTED.Core.UnitTests/bin/Debug/net6.0/REDACTED.Core.UnitTests.dll
  REDACTED.Data -> /usr/src/app/REDACTED.Data/bin/Debug/net6.0/REDACTED.Data.dll
  REDACTED.DomainServices -> /usr/src/app/REDACTED.DomainServices/bin/Debug/net6.0/REDACTED.DomainServices.dll

Build FAILED.
ChrisDeadman commented 2 years ago

I have the same issue, running any individual test gives me an issue like this:

[WARNING] Could not find a matching test directory for test KSPPartRemover.Tests.KspFormat.Objects.KspObjectTest

The file is located under KSPPartRemover.Tests/KspFormat/Objects/KspObjectTest.cs

DylanJVA commented 2 years ago

I am also having the same issue (with XUnit), trying to use the unit test explorer capability with QSharp applications. I can use the extension to run all tests, but individual ones do not work.

Upon running all tests: Test run for Executing dotnet build in /mnt/c/users/dylan/Documents/BWSI/UnitTesting/ Executing dotnet test --no-build --logger "trx;LogFileName=/tmp/test-explorer-UBCstp/0.trx" in /mnt/c/users/dylan/Documents/BWSI/UnitTesting/ Process 3125 started Process 3125 finished

Upon running an individual one: [WARNING] Could not find a matching test directory for test UnitTesting.HadamardQubit.QuantumSimulator.HadamardQubit

renataharcarik commented 8 months ago

If you feel like everything is set correctly and you still get this message you might need to press the refresh button so NUnit can find your newly added tests.

Screenshot 2023-10-25 at 10 59 50 PM