microsoft / microsoft/vscode-dotnettools
Test Explorer : Does not refresh test after build
@vsccarl is already working on this.
Since Jul 9, 2026.
- Dominant language
- No language data
- Stars
- 321
- Forks
- 54
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 2
Description
Describe the issue
There are a large number of issues in the Test explorer from the last couple DevKit releases.
Sometimes after a build, the tests are just not refreshed.
The Output for C# Dev Ket - Test Explorer reports:
2026-07-09 07:04:33.949 [debug] Skipping discovery for 'OpportunityOrchestrator.UnitTests' — project node has not been expanded yet.
which doesn't make sense.
- yes the project node is expanded (assuming this means the Test Explorer tree view)
- If I toggle open/close the project node in the tree view, it also doesn't perform a refresh, so even if it was closed, when I open the tree node it wouldn't have refreshed.
IMO it should always refresh
When it does refresh, it does not remove tests that no longer exist. For example after deleting or renaming some tests.
In this example I renamed 2 tests to TestOne and TestTwo, and deleted a test.
the Output for C# Dev Kit - Test Explorer reports:
2026-07-09 07:10:52.123 [debug] Project activated, adding project: OpportunityOrchestrator.UnitTests
2026-07-09 07:10:52.123 [debug] discoverTestsInProject: 'OpportunityOrchestrator.UnitTests'
2026-07-09 07:10:52.123 [info] Discovering tests in project '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/OpportunityOrchestrator.UnitTests.csproj' (TestingPlatform: False)
2026-07-09 07:10:52.124 [info] Discovery: /Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll (MTP: False)
2026-07-09 07:10:52.285 [info] [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 10.0.9)
2026-07-09 07:10:52.352 [info] [xUnit.net 00:00:00.06] Discovering: OpportunityOrchestrator.UnitTests
2026-07-09 07:10:52.567 [debug] Discovered 1000 test(s) [7e245a5e-4a78-476d-99be-a3fae931d786].
2026-07-09 07:10:52.650 [debug] Discovered 1000 test(s) [7e245a5e-4a78-476d-99be-a3fae931d786].
2026-07-09 07:10:52.722 [debug] Discovered 1000 test(s) [7e245a5e-4a78-476d-99be-a3fae931d786].
2026-07-09 07:10:52.722 [info] [xUnit.net 00:00:00.40] Discovered: OpportunityOrchestrator.UnitTests
2026-07-09 07:10:52.808 [debug] Discovered 953 test(s) [7e245a5e-4a78-476d-99be-a3fae931d786].
2026-07-09 07:10:52.808 [info] Discovery complete for '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll'
2026-07-09 07:10:52.808 [debug] Discovery complete [7e245a5e-4a78-476d-99be-a3fae931d786].
2026-07-09 07:10:52.809 [debug] Discovery marked complete for project '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/OpportunityOrchestrator.UnitTests.csproj[net10.0]' at 2026-07-09T11:10:52.809Z
This is my source code now:
Test explorer still shows tests that were deleted or renamed
Icons to run tests in source window do not always update. Look at the above screenshot again. You can see that it put an icon to run one of the tests in the left gutter, but not the other. This seems extra broken with collapsed sections. Sometimes the testing icon is on a line inside the collapsed area, not on the function definition. Sometimes the icons are not in sync with what the Test Explorer shows for that test.
Sometimes tests get 2 icons:
Clicking "run tests" button from the top bar of the Test Explorer, or from a parent node in the tree, triggers a rebuild of the project, but does not update the tests. Or perhaps it only runs the tests that it already knew about before the rebuild? Hard to tell exactly...
Open an existing test file, and add a new test:
[Fact]
public async Task TestThree()
{
throw new NotImplementedException();
}
Then click the "Run Tests" (play icon) button either on the top bar of the Test Explorer, or on the tree node for the Class. (In previous Dev Kit versions, this would have rebuild the code, refreshed the list of tests, then run all the newly found tests. It no longer does that.)
Output for Test Explorer is
2026-07-09 07:25:23.238 [debug] discoverTestsInProject: 'OpportunityOrchestrator.UnitTests'
2026-07-09 07:25:23.239 [info] Discovering tests in project '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/OpportunityOrchestrator.UnitTests.csproj' (TestingPlatform: False)
2026-07-09 07:25:23.239 [info] Discovery: /Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll (MTP: False)
2026-07-09 07:25:23.263 [debug] Started Task [Build 1 projects]
2026-07-09 07:25:23.266 [debug] All projects target net10.0, adding --framework flag.
2026-07-09 07:25:23.266 [debug] Batch building 1 projects via solution targets: tests\OpportunityOrchestrator_UnitTests
2026-07-09 07:25:23.406 [info] [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 10.0.9)
2026-07-09 07:25:23.475 [info] [xUnit.net 00:00:00.07] Discovering: OpportunityOrchestrator.UnitTests
2026-07-09 07:25:23.702 [debug] Discovered 1000 test(s) [287affb2-7e15-432b-ad23-2b261da7e010].
2026-07-09 07:25:23.803 [debug] Discovered 1000 test(s) [287affb2-7e15-432b-ad23-2b261da7e010].
2026-07-09 07:25:23.885 [debug] Discovered 1000 test(s) [287affb2-7e15-432b-ad23-2b261da7e010].
2026-07-09 07:25:23.885 [info] [xUnit.net 00:00:00.43] Discovered: OpportunityOrchestrator.UnitTests
2026-07-09 07:25:23.966 [debug] Discovered 954 test(s) [287affb2-7e15-432b-ad23-2b261da7e010].
2026-07-09 07:25:23.966 [info] Discovery complete for '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll'
2026-07-09 07:25:23.966 [debug] Discovery complete [287affb2-7e15-432b-ad23-2b261da7e010].
2026-07-09 07:25:23.967 [debug] Discovery marked complete for project '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/OpportunityOrchestrator.UnitTests.csproj[net10.0]' at 2026-07-09T11:25:23.967Z
2026-07-09 07:25:25.455 [debug] Completed Task [Build 1 projects]
2026-07-09 07:25:25.465 [debug] Switched focus to Test Results view
2026-07-09 07:25:25.466 [info] Running tests in project '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/OpportunityOrchestrator.UnitTests.csproj' (TestingPlatform: False)
2026-07-09 07:25:25.466 [info] Run: /Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll (MTP: False)
2026-07-09 07:25:25.467 [info] Run: 2 selected test(s)
2026-07-09 07:25:25.626 [info] [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.5+1b188a7b0a (64-bit .NET 10.0.9)
2026-07-09 07:25:25.706 [info] [xUnit.net 00:00:00.08] Starting: OpportunityOrchestrator.UnitTests
2026-07-09 07:25:25.990 [info] [xUnit.net 00:00:00.36] Finished: OpportunityOrchestrator.UnitTests
2026-07-09 07:25:26.012 [debug] Test result [98af96e3-66a2-43d0-8448-ef9af25e537c]: 83f6f136-e093-2d12-780f-1815e9ee9823 => Passed (266ms)
2026-07-09 07:25:26.012 [debug] Test result [98af96e3-66a2-43d0-8448-ef9af25e537c]: a0e02974-a451-2dc3-8fb0-9780e79c5e1e => Passed (7ms)
2026-07-09 07:25:26.012 [info] Run complete for '/Users/jeff.valore/Projects/opportunity-orchestrator/tests/OpportunityOrchestrator.UnitTests/bin/Debug/net10.0/OpportunityOrchestrator.UnitTests.dll'
2026-07-09 07:25:26.012 [debug] Test run complete [98af96e3-66a2-43d0-8448-ef9af25e537c].
so you can see in there that it did a rebuild then claims it refreshed the tests.
But it then says
2026-07-09 07:25:25.467 [info] Run: 2 selected test(s)
which is wrong. that does not include the test we just added.
The file has 3 tests:
It just didn't bother to run one. It feels like it uses the known test names at the time you click "run tests" from a parent node, then does a rebuild and refresh, but still only runs the tests that were known at the time the test run was initiated?
This all combines to be a bad experience, and makes the Test Explorer results so they can't be trusted. I'll frequently click "Run All Tests" from the Test Explorer top bar and get all passing tests, but tests that were recently added will fail if run through dotnet test on a command shell, since Test Explorer insists on not refreshing what tests exist.
Collect logs
(log snippets inserted into comments above)
Steps to reproduce
Use C# Dev Kit with xUnit.
Expected behavior
Test Explorer worked fine for years. Now it is wildly unreliable. It should always report the same results as dotnet test from from a shell.
Environment information
VSCode:
Version: 1.128.0 (Universal)
Commit: fc3def6774c76082adf699d366f31a557ce5573f
Date: 2026-07-07T15:14:24-07:00
Electron: 42.5.0
ElectronBuildId: 14525058
Chromium: 148.0.7778.271
Node.js: 24.17.0
V8: 14.8.178.33-electron.0
OS: Darwin arm64 25.5.0
C# Dev Kit
3.20.199
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.