-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Provide example for .NET coverage * Remove coverlet from refs
- Loading branch information
Showing
12 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: .NET - coverlet test coverage | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- 'releases/*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0' | ||
|
||
- name: Add coverlet dependencies | ||
working-directory: NET/coverlet/UnitTestProject | ||
run: | | ||
dotnet add package coverlet.msbuild; dotnet add package coverlet.collector | ||
- name: Build solution | ||
working-directory: NET/coverlet | ||
run: dotnet build | ||
|
||
- name: Run tests with code coverage | ||
run: dotnet test /p:CollectCoverage=true /p:CoverletOutput=../.qodana/code-coverage/ /p:CoverletOutputFormat=lcov | ||
working-directory: NET/coverlet | ||
|
||
- name: Archive coverage data | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: net-coverage-data | ||
path: NET/coverlet/.qodana/code-coverage | ||
|
||
- name: Qodana Scan | ||
uses: JetBrains/qodana-action@main | ||
env: | ||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_NET }} | ||
with: | ||
args: "-i,NET/coverlet,--linter,jetbrains/qodana-dotnet:latest" | ||
pr-mode: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace QodanaCoverageTest; | ||
|
||
public class Class1 : Interface1 | ||
{ | ||
public Class1() | ||
{ | ||
var y = 5; | ||
Check warning on line 7 in NET/coverlet/Class1.cs
|
||
} | ||
|
||
public void UsedMethod() | ||
{ | ||
LocalMethod(); | ||
void LocalMethod() | ||
{ | ||
var x = 5; | ||
Check warning on line 15 in NET/coverlet/Class1.cs
|
||
} | ||
void UnusedLocalMethod() { } | ||
Check warning on line 17 in NET/coverlet/Class1.cs
|
||
} | ||
|
||
public void UsedMethodWithIf(int i) | ||
{ | ||
if (i == 1) | ||
{ | ||
Console.Write(i); | ||
} | ||
else | ||
{ | ||
Console.Write(i); | ||
Console.Write(i); | ||
} | ||
} | ||
|
||
public int UsedLambdaMethod() => 4; | ||
|
||
public int UnusedLambdaMethod() => 5; | ||
|
||
private void UnusedMethod() | ||
{ | ||
void UnusedLocalMethod() | ||
Check warning on line 39 in NET/coverlet/Class1.cs
|
||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace QodanaCoverageTest; | ||
|
||
public class Class2 | ||
{ | ||
public Class2() | ||
{ | ||
|
||
} | ||
|
||
public void UnusedMethod() | ||
{ | ||
|
||
} | ||
|
||
public int MyProperty => 42; | ||
|
||
public int MyProperty1 | ||
{ | ||
get => MyProperty; | ||
set => MyProperty2 = value; | ||
} | ||
|
||
public int MyProperty2 | ||
{ | ||
get; | ||
set; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace QodanaCoverageTest; | ||
|
||
public enum Enum1 | ||
{ | ||
VAL1, | ||
VAL2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace QodanaCoverageTest; | ||
|
||
public interface Interface1 | ||
{ | ||
void Foo() | ||
{ | ||
|
||
} | ||
|
||
void Bar() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace QodanaCoverageTest; | ||
|
||
public class NotInReportClass : Interface1 | ||
{ | ||
public NotInReportClass() | ||
{ | ||
var y = 42; | ||
Check warning on line 7 in NET/coverlet/NotInReportClass.cs
|
||
} | ||
|
||
public void UsedMethodWithIf(int i) | ||
{ | ||
if (i == 1) | ||
{ | ||
Console.Write(i); | ||
} | ||
else | ||
{ | ||
Console.Write(i); | ||
Console.Write(i); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="UnitTestProject\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Remove="UnitTestProject\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="UnitTestProject\**" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QodanaCoverageTest", "QodanaCoverageTest.csproj", "{2849E952-A756-4191-AC98-AF80D2848500}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "UnitTestProject\UnitTestProject.csproj", "{4ED497EE-E195-4408-B5B9-861FED661884}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2849E952-A756-4191-AC98-AF80D2848500}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2849E952-A756-4191-AC98-AF80D2848500}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2849E952-A756-4191-AC98-AF80D2848500}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2849E952-A756-4191-AC98-AF80D2848500}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4ED497EE-E195-4408-B5B9-861FED661884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4ED497EE-E195-4408-B5B9-861FED661884}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4ED497EE-E195-4408-B5B9-861FED661884}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4ED497EE-E195-4408-B5B9-861FED661884}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using QodanaCoverageTest; | ||
|
||
namespace UnitTestProject; | ||
|
||
public class Tests | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
} | ||
|
||
[Test] | ||
public void Test1() | ||
{ | ||
var cls = new Class1(); | ||
cls.UsedMethod(); | ||
cls.UsedMethodWithIf(1); | ||
cls.UsedLambdaMethod(); | ||
Assert.Pass(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"/> | ||
<PackageReference Include="NUnit" Version="3.13.3"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.5.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\QodanaCoverageTest.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using NUnit.Framework; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
profile: | ||
name: qodana.single:NetCoverageInspection |