-
Notifications
You must be signed in to change notification settings - Fork 16
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] C# dev kit for xUnit not discovering tests #307
Comments
I figured why this was not working. The .sln file needed to be updated with the new test project. After I added this in Visual Studio, I could discover the tests in VS Code. Perhaps the aforementioned documentation could be checked to see if the setup instructions are correct? https://code.visualstudio.com/docs/csharp/testing. |
Thanks for the additional info @snowberry-clearwing. Just to confirm you already had an existing solution open, but you created the new test project and it didn't automatically add it to your open solution? |
Yes, that is correct. I ran the 'dotnet add' command to ensure the project was added however the solution file still had to be fixed externally. |
Thanks @snowberry-clearwing -- so your steps were:
|
|
I am also facing the same issue. Just installed C# DevKit - I cloned this repo - https://github.com/anuraj/MinimalApi - In the editor I couldn't find any option to execute the tests. I tried to remove the test project and added it again. I tried |
Hi @anuraj - in VS Code there is a "Test Explorer" area as seen here where the tests show up. After a build the tests will be discovered here: |
I have the same issue, the tests do not show up within this view. |
I can't get my new test to show up. If I run dotnet test, all the tests run, but the Test Explorer doesn't show it. Only thing that works is restarting Vscode. |
This is still broken. None of my xunit tests are being discovered. Rebuilt. Re added to sln. Re installed vscode 1.84. Re installed dev kit. Still broken |
@wgrs is this a repo perhaps we can look at? What target framework versions are the tests/projects? |
It's targeting 8. Calling dotnet test blows up with a missing testhost runtime json file error. Its a brand new install on Ubuntu 23.10. Should be easy to replicate. |
Ok, the blow up on the CLI alone could be a root cause here (stating the obvious). How did you install on Ubuntu? apt-get? Can you put the error on the dotnet-test issue here as well? |
Yes APT. Yes, will report on dotnet test |
This is the error being produced when I try and run dotnet test on Ubuntu on .Net 8. I have checked and the reference to the file below is missing. |
Hmm… @peterwald this seems more fundamental on the environment. |
I faced the same problem having projects and .sln file under a src/ folder. Reverted C# Devkit to previous version and it's working again. (from 1.0.14 to 0.5.150) |
This seems to be an issue with the local |
@peterwald, Closing this as "not reproducable" probably won´t help those people facing the issue (like me today). I had tests showing up in one solution, but not in another. working solution:
non-working solution:
Just got hands on a fresh dev-machine (MacOS Sonoma@M3 Max) and double checked everything against the former rig (Windows 11@Intel). The former (windows-)rig (where both solutions were successfully discovering tests in test-explorer) has
installed. The new (MacOS)-machine only has
installed. I then just modified the test-project to target Seems as if the matching target-framework of the test-assembly has to be installed on the machine in order to let test-explorer discover tests. Hope this might help anybody else facing a similar situation. |
Facing the same issue here. I am using C# Dev Kit with Docker and Devcontainer. My machine is running Ubuntu but the project is opened inside the Docker container. I have So what I did was to open the folder, containing the Unit tests project in the Terminal and run |
@westsiderz Which version does your test-project built against? For me, the issue was solved once the machine had the proper sdk-version installed (or the test-project actually compiled against a version that is present on the machine, respectively). Probably also the case for a devcontainer?! So either switch your test-projects target-framework or add the matching. net-sdk in your Container might help? |
My Test-Project buids against
|
I'm also having this issue. No matter what I try it says no test have been found even though the sln has the test project and dotnet test runs the tests properly. I am running in MacOS with all projects targeting 8.0. |
The following steps should work to get some sample xUnit tests working as a baseline for comparison. Prerequisites
Steps
After initialization is complete, the test explorer panel should show the sample test from this project. |
Maybe late but this work, I used this when I create a new test to my c# project, now it works correctly ! |
I find that I have to do an |
Unfortunately I still have the same problem on mac, I tried every solution provided. |
I also had this. Test explorer has been working and stopped all of a sudden. Build and clean did nothing. Restarting vscode did nothing. Even typing Tests in the command palette returned no results. There were no errors in the output panel. There was nothing left to try. Two days later and a few restarts later the tests show up. So I cannot reproduce the issue either. |
For me the test project at least need to be net7.0 for the test runner to detect the unittests. |
Cleaning the test store folder helped. You can find it in the Output -> C# Dev Kit tab
|
You're a live saver @amakhno !!! |
Describe the Issue
I am using the C# dev kit extension for unit testing with xUnit. It was able to discover the tests that were already in the project when the addon was installed, however I cannot discover new tests. I am not sure if I am missing a setting somewhere, however I could not find any relevant documentation apart from https://code.visualstudio.com/docs/csharp/testing.
Steps To Reproduce
Expected Behavior
When I hit the 'Refresh Tests' icon in the Test explorer I would see updated tests.
Environment Information
OS: WIndows 11
VS Code version: 1.80.2 (user setup)
Extension: v0.2.100
The text was updated successfully, but these errors were encountered: