Skip to content
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

Cannot run C# tests #2544

Closed
denisvlah opened this issue Sep 20, 2018 · 8 comments
Closed

Cannot run C# tests #2544

denisvlah opened this issue Sep 20, 2018 · 8 comments

Comments

@denisvlah
Copy link

Environment data

.NET Core SDK: 2.1.401
OS Name: ubuntu 16.04
VS Code version: 1.27.1
C# Extension version: 1.16.1

Steps to reproduce

  1. Open folder in VSCode with C# netcore solution.
  2. Wait for OmniSharp to load completely.
  3. Open xUnit test file

Expected behavior:

Links Run|Debug should appear above each test method

Actual behavior:

Links Run|Debug don't appear.

It worked in previous version. Also it works on small projects.
The OmniSharp log is ok - no error messages.
At the same time the OmniSharp icon display that it has errors:
image

Also there are errors in Window log.
I have also attached the VSCode Window log with errors:
WindowLog.txt

And OmniSharp log:
OmniSharpLog.txt

@akshita31 akshita31 self-assigned this Sep 20, 2018
@akshita31
Copy link
Contributor

@denisvlah The red error flame is not because of omnisharp process crashing. It is because of a typical mono behavior and we have already fixed that in master: #2540.

From your omnisharp log I don't see any error being printed. Since you are saying that it works on small projects, can you try "omnisharp.projectLoadTimeout" to a higher value and then "Ctrl+Shift+P --> Restart Omnisharp"?

@akshita31
Copy link
Contributor

@denisvlah Any updates here ?

@denisvlah
Copy link
Author

denisvlah commented Oct 3, 2018

The OmniSharp doesn't timeout. Intelicence and code navigation and code suggestions works perfect, it just not show links to run tests.
Also I have tried it on Windows with the same solution and it worked.
Also a few words about solution - it has 2 .csproj files in the same folder. They are related to different solutions. One project is for netcore and the second one is for full framework.
On the Windows where I can run tests it display links but fails to run. It complaints that folder has 2 project files. If there is only 1 project file it works fine.

Update:
I have elaborated a solution with project files that can reproduce the issue. Check the attached file.
Steps to reproduce:
1 ) Open attached folder.
2) Wait Until OmniSharp is started and loaded.
3) Notice that it displays links "Run Test | Debug Test" correctly in the file CalculatorTest.cs
4) You should also notice a suggestion from C# extension to restore dependencies. Click "Restore"
5) Close the visual studio code
6) Open folder in visual studio code
7) Wait until OmniSharp is started and loaded.
8) Open file CalculatorTest.cs and observe that there is no links "Run Test | Debug Test". It is supposed to be displayed.

Also notice that the custom TestAttribute is inherited from Xunit.Fact and it is used to mark test method in CalculatorTest class. If you use standard Fact attribute it works fine. It worked fine in the previous version.

In my prod environment I have ported hundreds Nunit tests to Xunit testing framework using such kind of hack.
OmniSharp_UnitTest_with_links_bug.zip

@akshita31
Copy link
Contributor

@denisvlah I can totally reproduce the problem.

More information:
In my developer console, I see that there was an error.
image

We will get it resolved as soon as possible. Thank you for your patience.

@akshita31 akshita31 added the Bug label Oct 9, 2018
@akshita31
Copy link
Contributor

image

There is an argument exception in the omnisharp process, due to which the codelens is not appearing.

@akshita31
Copy link
Contributor

On investigating further, the line here is throwing the exception:
https://github.com/OmniSharp/omnisharp-roslyn/blob/fe68d63b16fb44b2e647f538ffd8b1ec95fabb0e/src/OmniSharp.Roslyn.CSharp/Services/Structure/CodeStructureService.cs#L365

Because it is adding two values for the same key -"testFramework" - xunit and nunit

@akshita31
Copy link
Contributor

When I changed the namespace "NUnit.Framework" to "abc.Framework", everything works fine.

@denisvlah
Copy link
Author

Closing this issue as it is very specific to the project I am working on and a better way to go is to refactor all tests to use NUnit3 with standard [Test] without additional hacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants