Skip to content

Commit

Permalink
Added test coverage to action (#36)
Browse files Browse the repository at this point in the history
* Added test coverage to action

* Adjusted report generation

* Added some basic logic to dummy test

* removed unnecessary ()
  • Loading branch information
Hutch79 authored Aug 20, 2024
1 parent 346e8ae commit 08f094c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ jobs:
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Find coverage reports
id: find-reports
run: |
echo "::set-output name=paths::$(find ${{ github.workspace }} -name "coverage.cobertura.xml")"
- name: Send coverage-reports to Codacy
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ steps.find-reports.outputs.paths }}
6 changes: 5 additions & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

</Project>
13 changes: 11 additions & 2 deletions Test/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Domain;

namespace Test;

public class UnitTest1
Expand All @@ -9,6 +11,13 @@ public void Test1()
// What did you expect, im lazy!
// Ok, jokes aside. There will be unit tests which will be (hopefully) better than this.
// But currently there are none.
Assert.True(true);

var user = new User
{
Email = "[email protected]",
Username = "test",
};

Assert.Equal("[email protected]", user.Email);
}
}
}
9 changes: 9 additions & 0 deletions Your-Lab.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Application", "Application\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{B0AA861A-78A9-44BC-A4BF-521ED3E2BAAD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub-Actions", "GitHub-Actions", "{84E7E444-CAB6-49D1-93DB-6C11B88E3437}"
ProjectSection(SolutionItems) = preProject
.github\workflows\docker-image.yml = .github\workflows\docker-image.yml
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -48,4 +54,7 @@ Global
{B0AA861A-78A9-44BC-A4BF-521ED3E2BAAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0AA861A-78A9-44BC-A4BF-521ED3E2BAAD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{84E7E444-CAB6-49D1-93DB-6C11B88E3437} = {3E27F210-D21B-4A7A-ADC3-950AA278E483}
EndGlobalSection
EndGlobal

0 comments on commit 08f094c

Please sign in to comment.