Closed MartinHaeusler closed 5 years ago
Hello, we do not require a dedicated "test project", but we do need to know how to discover your tests.
Is there a .sln or .csproj file in your root folder (eg the folder containing main and test) or can you elaborate a bit more about what your setup is?
It's a really basic setup - I only did a dotnet new console
in an empty folder. This creates a new .csproj file. In this root, I have one folder for the actual project .cs files, and one for the tests.
Then I added NUnit to the project:
dotnet add package Microsoft.NET.Test.Sdk
dotnet add package Nunit3TestAdapter
dotnet add package NUnit
Maybe not all of them are required, I followed a guide. Then I added a test.cs file to the test folder, containing a class with a method annotated as [Test]
.
This test can be executed just fine using the microsoft C# plugin. Unfortunately it doesn't show up in the .NET Test Explorer provided by this plug-in.
Do you think this might be added to the plugin? Or did I do somthing wrong? I'm coming from the Java world, C# is still new territory for me.
If I follow that guide the test explorer is working as expected.
When you say that the plugin doesn't detect them, what do you mean? If you look at the test explorer view what do you see?
Hi,
sorry but I get a different result... Here are the sources of my "project": netCoreProject.zip
For me it looks like this:
... and the .NET Test Explorer view says:
I tried setting the test project path in the settings (to the same project which is currently open), but unfortunately the situation did not change.
Am I doing something wrong in my setup? As I said, I can run the tests just fine with the CodeLens commands, I just don't see them in the .NET test explorer.
When I open your project I can see the test explorer.
If you in a terminal window that's in the root directory (where the netCoreProject.csproj is located) and you run the command "dotnet test -t -v=q" what do you see then?
I ran the command dotnet test -t -v=q
and indeed it lists all my test methods in the console.
I just realized that there's a "Show Log" button in the .NET Test Explorer header. Here's what it says:
Starting extension Finding projects for pattern d:\projects\netCoreProject/ Found 1 matches for pattern in folder d:\projects\netCoreProject Evaluating match d:/projects/netCoreProject/ Adding directory d:/projects/netCoreProject/ Executing dotnet test -t -v=q in d:/projects/netCoreProject/ Executing dotnet test -t -v=q in d:/projects/netCoreProject/
Looks alright to me? When I run the command manually in the VSCode integrated terminal I get a listing of all test methods.
Hmm yea that looks like an expected outcome.
If you execute "dotnet --version" in a terminal, what is shown then?
Hi, sorry for the late reply, busy times...
The output of dotnet --version
produces 2.1.101
.
Here's the list of the plugins I currently have installed:
... maybe something is conflicting here?
Ah ok, as noted on the prereq notes you need to run a higher version of the sdk when using nunit (https://github.com/formulahendry/vscode-dotnet-test-explorer#prerequisites). Try and upgrade your sdk version and see if that helps.
Oh gosh. Thanks for the pointer, I totally missed that (perhaps you could add a warning in the UI somewhere if the prerequisites aren't met?).
Microsoft just made me jump through quite some hoops to get this working (I'm leaving this description here just in case someone else bumps into the same problem):
zh-Hans
and zh-Hant
, as well as deleting the de
folder in the dotnet sdk install directory, I forced the CLI to revert back to its default language, which is english. Extremely hacky, but according to the open dotnet github issues, there's currently no other way.And now, after all this, plus restarting my computer about 3 times (because Microsoft), I'm finally able to see my tests in the .NET Test explorer.
I can also click "play" and in the "Test Explorer" log in VSCode it is clearly running the tests to completion, but unfortunately the .NET Explorer UI doesn't update - the spinning indicator just keeps on spinning even though the tests are long done. Any tips for that one?
@MartinHaeusler It might be that vscode lacks access to read the test result. Check out https://github.com/formulahendry/vscode-dotnet-test-explorer#test-result-is-not-shown-in-codelens--tree and see if that helps.
I'll close this issue since the issue title no longer is relevant.
Hi,
I just tried to use your plugin. I've got a very simple C# project, two root folders "main" and "test" separate test code from production code.
It would be very handy if your plug-in could search for Nunit tests within the current project, rather than requiring a dedicated "Test Project". Running the tests from the CodeLens-links works fine in VSCode, but unfortunately your plugin doesn't detect them.