-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Test Explorer Does Not Refresh Tests #252
Comments
Git branch switching appears to suffer from the same issue (e.g., the "switched-to" branch includes new/removed unit tests). |
@acgritt do you perform a build after adding the new tests? |
Can confirm on my system. Multi-root (with .NET project in a second folder), I'm adding a new xUnit test file, then build/rebuild/cleanbuild/build+run/restart VSC and no matter what I do it doesn't show in Test Explorer. So I went to Visual Studio an it's shown right away (no build or anything). I run it. After that it's also shown in VS Code. Is it like about some kind of tests cache that's only "big" VS can create? VSCode 1.80.1, C# 2.0.249 (pre-rel), C# Dev Kit 0.3.2 (pre-rel) |
@timheuer Yes, I do a build after adding the new tests. Nothing shows up in the explorer. Same happens if I remove or rename a test. The explorer doesn't change. When I "Reload Window" in VS Code or close and relaunch then the updated list of tests shows after I run the build again, but it is not refreshing the list without a heavier hand on the refresh process. |
I started running into this after re-structuring my solution a bit. It was showing duplicate tests, tests I removed, and was using the wrong path to look for the A workaround was to remove the test store. If you check the solution explorer extension output it will tell you the location on startup:
In there I deleted the |
I am also having this problem, and can confirm that solution does work to a degree. Update: The issue has now resolved itself, and now all i have to do to get the tests to show up is build the project. No idea what fixed this or how to reproduce the problem. |
i always need to use |
I managed to resolve it by removing the |
I'm experiencing similar issues when changing the build target. Duplicate tests, errors trying to load invalid assembly, etc. The only way to resolve these issues is to delete the testStore under workspaceStorage. @ProTip Thank you for posting that workaround, was getting very frustrated with bad tests until I found this. |
@ivanjx @LynxWall @acgritt @jpringle1 @ProTip Can you give me an idea of what the structure of your multi-root workspace looks like? Do you have all of your C# code & tests in one root, and other languages in the other roots? (i.e. javascript, web assets, etc...) Or are you creating a solution that somehow spans C# projects across multiple workspace roots? |
@peterwald
The workspace is set to display the src folder as Source and docs as Documentation at the root. Sometimes, when working with a dotnet angular project I also have Angular as a folder that points to the client folder inside the API project. When I click the refresh button to refresh the tests the status line that appears just blips and the logs show nothing as having been done. It isn't until I reload the VS Code window that the new tests show up. |
A fix has been merged and will be available in the next pre-release build. |
I am assuming this fix has been released in a pre-release build. I am running C# Dev Kit v0.5.150 and I am still experiencing the following issues.
Executing The layout is:
|
It looks like the test explorer is creating binaries in bin/Debug/net6.0//... bin/Debug vs bin/x64/Debug |
@tatejones C# Dev Kit v0.5.150 should include the fix I referenced above. The test explorer invokes the build command provided by the solution/project, it doesn't do anything special on its own. This should be the same as right clicking the Project or Solution node in the Solution Explorer section of the file pane and selecting build from there. When you say...
What does that mean? Which VSTest Adapter? Are you looking at what |
When I perform a build at the solution or project (right click in solution explorer) level I see binaries been created with the platform
/bin/x64/Debug/net6.0/...
When I execute a test using the test explorer the build doesn’t have the platform.
/bin/Debug/net6.0/...
What does that mean? Which VSTest Adapter? Are you looking at what dotnet test does on the command line?
From the Test Explorer, not via the command line.
The output -
Executing task: dotnet build /home/tate/code/<project>.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
MSBuild version 17.4.8+6918b863a for .NET
MSBuild version 17.4.8+6918b863a for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Utilities -> /home/tate/code/<Solution>/<Project>.Utilities/bin/Debug/net6.0/Utilities.dll
....
Any changes made are not detected for the tests to pick up. Strange
… On 7 Oct 2023, at 1:19 am, Peter Waldschmidt ***@***.***> wrote:
@tatejones <https://github.com/tatejones> C# Dev Kit v0.5.150 should include the fix I referenced above.
The test explorer invokes the build command provided by the solution/project, it doesn't do anything special on its own. This should be the same as right clicking the Project or Solution node in the Solution Explorer section of the file pane and selecting build from there.
When you say...
VSTest Adapter v2.5.0.1+5ebf84cd75 (64-bit .NET 6.0.22) is looking for binaries in the bin/x64/Debug/net6.0/
What does that mean? Which VSTest Adapter? Are you looking at what dotnet test does on the command line?
—
Reply to this email directly, view it on GitHub <#252 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AADONC2I5RSQ4NMZ4BXZCW3X6AORZAVCNFSM6AAAAAA2I5I3LKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQHA4DGMBYGI>.
You are receiving this because you were mentioned.
|
When it is discovering tests the log indicates it is searching through the binaries that have a platform in the path. In Summary:
Hence the VSTest Adapter never see a new build unless a build is manually triggered by the Solution Explorer or via the command line that includes the platform. The trigger that builds the binaries from the Test Explorer needs to use the same build instructions that of the Solution Explorer. |
FWIW I am seeing the same issue on a node.js project. New tests incoming from a git pull are not detected in Test Explorer, nor do they have the test controls (run, debug) in the gutter area. |
C# Dev Kit only supports C# projects. A node.js extension for VS Code should be able to help with node.js tests. |
The solution for me was to introduce another platform. Originally I had only x64 for Release and Debug. The test adapter was always specifying a platform (project level?), hence was missing the build that didn't have a platform. Once I added another platform like "AnyCPU" the build finally added the platform and then the test adapter picked it up. According to the docs. "If a project supports multiple platforms, a solution configuration is either found or added for each supported platform. The name of each solution configuration includes both the project configuration name and the platform name, and has the form < project configuration name > < platform name >." |
Refresh button does nothing for me. I have to restart VS Code to get new tests, every time I add a new one. 😞 |
I have the same issue. I need to do CTRL+SHIFT+P and run I've configured the outputs from build to end up in the <Project>
<PropertyGroup>
<BaseOutputPath>$(MSBuildThisFileDirectory)artifacts\$(MSBuildProjectName)\bin</BaseOutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)artifacts\$(MSBuildProjectName)\obj</BaseIntermediateOutputPath>
</PropertyGroup>
</Project> I have two solution (.sln) files in the root directory, one of them is default in {
"dotnet.defaultSolution": "Main.sln"
} All code is in the About VS Code
|
I can also confirm that changing <Project>
<PropertyGroup>
<BaseOutputPath>$(MSBuildThisFileDirectory)artifacts\$(MSBuildProjectName)\bin\AnyCPU</BaseOutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)artifacts\$(MSBuildProjectName)\obj\AnyCPU</BaseIntermediateOutputPath>
</PropertyGroup>
</Project> None of my projects targets any specific platform. Here is an example from a .csproj file. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
</ItemGroup>
</Project> |
Took a while to figure this out, but one of my devs picked a specific csproj file when the solution first loaded in vscode. From then on it would only load tests for that project. We were able to fix this by deleting the cache output in the C# Dev Kit log. Although thinking about it, we might have been able to fix this by adding the additional projects to the solution explorer. So, the dirty fix is to find the path to the C# Dev Kit cache in the in VSCode Output container/tab panel and delete the cache. Looks something like this: Then, reload VSCode, and when the popup to select the project appears, select the solution instead of a specific project. The Test explorer should then try to find tests in all the projects. References: |
I've been using tests all day and they just stopped working. This has happened before many times. Restarting, deleting bin, rebuilding, cleaning...nothing works, Strangely enough I tried Window Reload (read about it above) and this fixed it, at least it fixed it right now. This issue is very derailing. |
Thanks for sharing your feedback folks. I'm re-opening this issue so we can take another look at why this is as flaky. Based on the comments here, it might be tied to this issue: #996 , we've been tracking with the filewatcher API in VSCode. The workaround there was to delete the bin+obj folders on all the projects, reopen vscode and trigger a build. That's a little on the heavy-handed side compared to the window reload workaround posted earlier. However tagging @ocallesp on this so we can investigate what is happening here and verify if it is the same problem as the one linked. If anyone has a sharable repro that could help us track this down, that would be very much appreciated as well. |
Describe the Issue
This seems to be related to using a multi-root workspace as when commenting out the folders it works fine. When adding new Unit Tests and building the Test Explorer is not updating to reflect the new tests. I tried clicking the refresh button in Test Explorer and when I choose Run All Tests the tests do not appear to be run. If I reload the window in VS Code then when it loads the Test Explorer all the new tests show up.
Steps To Reproduce
Expected Behavior
Adding new unit tests to the loaded solution should cause the Test Explorer to refresh and show the new tests.
Environment Information
No response
The text was updated successfully, but these errors were encountered: