-
Notifications
You must be signed in to change notification settings - Fork 0
Test coverage config #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
bd3b092
42a9ddd
7b1f86c
710e6d1
80c7ad4
abfa379
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| record Pattern(string Value) | ||
| { | ||
| public string SomeMethod => Value; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to trigger failing test coverage report |
||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually in c# .NET you do <proj_name.Tests>. So for our test proj it should be PatternService.Tests. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
|
|
||
| <IsPackable>false</IsPackable> | ||
| <IsTestProject>true</IsTestProject> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
| <PackageReference Include="xunit" Version="2.5.3" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Include="Xunit" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\PatternService\PatternService.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <CollectCoverage>true</CollectCoverage> | ||
| <CoverletOutput>../TestResults/coverage/</CoverletOutput> | ||
| <CoverletOutputFormat>cobertura</CoverletOutputFormat> | ||
| <Threshold>100</Threshold> | ||
| <ThresholdType>method</ThresholdType> | ||
| <ThresholdStat>Total</ThresholdStat> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace PatternServiceTests; | ||
|
|
||
| public class UnitTest1 | ||
| { | ||
| [Fact] | ||
| public void Test1() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make a local method just in this class to make the test fail to prove that the CI-pipeline fails: [Fact]
public void ThisTestWillFail()
{
Assert.Equal(5, Add(2, 2));
}
private int LocalTestAdd(int x, int y)
{
return x + y;
} |
||
| { | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <RunSettings> | ||
| <DataCollectionRunSettings> | ||
| <DataCollectors> | ||
| <DataCollector friendlyName="XPlat Code Coverage"> | ||
| <Configuration> | ||
| <CodeCoverage> | ||
| <ModulePaths> | ||
| <Include> | ||
| <ModulePath>.*PatternService.*</ModulePath> | ||
| </Include> | ||
| </ModulePaths> | ||
| <Exclude> | ||
| <Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute> | ||
| <Module>.*Test.*</Module> | ||
| </Exclude> | ||
| <Thresholds> | ||
| <Threshold type="method" value="100" /> | ||
| </Thresholds> | ||
| </CodeCoverage> | ||
| </Configuration> | ||
| </DataCollector> | ||
| </DataCollectors> | ||
| </DataCollectionRunSettings> | ||
| </RunSettings> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the
coverage.runsettingshere is the file you have created, this will not find the file as it is looking for this file in this folder. I belive you can use${{ github.workspace }}/coverage.runsettings.${{ github.workspace }}should point to the project root folder if I'm not wrong.