question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XUnit code lens (run test, debug test) not appear in solution workspace

See original GitHub issue

From @luktar on December 21, 2017 18:25

VScode version: 1.19 OS: Mac OS X Hight Sierra

Similar https://github.com/OmniSharp/omnisharp-vscode/issues/1292

XUnit code lens appears in the project like workspace (one project only - csproj on top level). XUnit code lens does not appear in the solution like workspace (sln on a top level, projects inside folders).

Steps to reproduce:

  1. Create solution ‘dotnet new sln’
  2. Create test folder ‘mkdir Test’, ‘cd ./Test’
  3. Create test project ‘create classlib’
  4. Put this to csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
  </ItemGroup>
</Project>
  1. Open workspace on csproj level, open test class - code lens appears.
  2. Open workspace on sln level, open test class - code lens doesn’t appear.

Copied from original issue: Microsoft/vscode#40666

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DustinCampbellcommented, Jan 24, 2018

Glad to see that everything is working properly. Thanks for following up!

2reactions
luktarcommented, Jan 24, 2018

Hello @DustinCampbell . I mean that I forgot to add a step with adding a test project to the solution.

Everything is working fine!

I don’t know the reason what was wrong.

I’ve made small research and I tried to reproduce exact environment for not showing code leans descriptions for tests. I had two solution types in one directory. I can’t edit test description, so I’ve made new below:

  1. Create new ConsoleApplication in regular .Net (I used 4.6.1) by Visual Studio 2017 in directory X.

  2. Create solution dotnet new sln -n CodeLensTest

  3. Create test folder mkdir Test, cd ./Test

  4. Create test project dotnet new classlib

  5. Add project to solution dotnet sln ../CodeLensTest.sln add ./test.csproj

  6. Add this code to ./Test/Class1.cs

using System;
using Xunit;

namespace test
{
    public class Class1
    {
        [Fact]
        public void Test1()
        {
            
        }
    }
}
  1. Put this to csproj
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
  </ItemGroup>
</Project>
  1. Build project cd .. dotnet build CodeLensTest.sln

  2. In VSCode open workspace on .Test/test.csproj level, open test class - code lens appears.

  3. In another window of VSCode open workspace on ./CodeLensTest.sln level, open test class - code lens doesn’t appear.

In step 10 VSCode shows code lens!

csproj level:

csprop level

sln level:

sln level

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Debug Test option in code lens in VSCode for NUnit ...
"Run Test"/"Debug Test" is not showing up in Code Lens for a particular C# project. This particular project is using the NUnit test...
Read more >
Debug / Run part of unit test CodeLens for is not showing
Create new unit test project, build it. ... This issue is read only, because it has been in the Closed - Fixed state...
Read more >
Getting Debug Test Option In Code Lens In Vscode For Nunit C#
With a test file open, select the Run Test CodeLens adornment that appears above a test with "request":"test" , the first definition will...
Read more >
NETCore.With("vsCode").Should().Have("Unit Tests") - Xpirit
NET Core framework and the VS Code editor. We assume you have a basic understanding of unit testing and mocking in .
Read more >
Automatic Unit Testing in .NET Core plus Code Coverage in ...
NET Core as expected. That means we can just "dotnet test" and it'll build and run tests. Added coverlet, which integrates with MSBuild...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found