Skip to content

Commit

Permalink
switch from dorny/test-reporter to test-summary/action
Browse files Browse the repository at this point in the history
- test results will be included in the job summary
- simplifies actions
- requires use of junit output test-summary/action#1
- added publish and upload artifact steps
- committing with failing test to ensure it works when tests fail
  • Loading branch information
wicksipedia committed Dec 13, 2023
1 parent e3b2af4 commit e2d6b47
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET
name: Build and test

on:
push:
Expand All @@ -12,11 +9,10 @@ on:
jobs:
build:
name: "Build"

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Cache
uses: actions/cache@v3
Expand All @@ -36,12 +32,26 @@ jobs:
run: dotnet build --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --no-restore --configuration Release --logger "trx;LogFileName=TestResults.trx"
run: dotnet test --no-build --no-restore --configuration Release --logger "junit;LogFilePath=results/tests.xml"

# as per https://github.com/dorny/test-reporter?tab=readme-ov-file#recommended-setup-for-public-repositories
- name: Test Report
- name: Publish
run: dotnet publish src/WebApi/WebApi.csproj --no-build --no-restore --configuration Release --output ./publish

- name: Upload Artifact
uses: actions/upload-artifact@v3
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: "**/*.trx"
name: published-files
path: ./publish

- name: Test Report
uses: test-summary/action@v2
if: success() || failure()
with:
paths: results/**/*.xml
output: test-summary.md
- name: Output job summary
if: success() || failure()
run: |
cat test-summary.md >> $GITHUB_STEP_SUMMARY
24 changes: 0 additions & 24 deletions .github/workflows/test-report.yml

This file was deleted.

1 change: 1 addition & 0 deletions tests/Architecture.Tests/Architecture.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="JunitXml.TestLogger" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NetArchTest.Rules" />
<PackageReference Include="xunit" />
Expand Down
43 changes: 21 additions & 22 deletions tests/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageVersion Include="xunit" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="NetArchTest.Rules" Version="1.3.2" />
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="Respawn" Version="6.1.0" />
<PackageVersion Include="Testcontainers" Version="3.6.0" />
<PackageVersion Include="Testcontainers.SqlEdge" Version="3.6.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Meziantou.Extensions.Logging.Xunit" Version="1.0.7" />
</ItemGroup>
</Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="JunitXml.TestLogger" Version="3.0.134" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageVersion Include="xunit" Version="2.6.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="NetArchTest.Rules" Version="1.3.2" />
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="Respawn" Version="6.1.0" />
<PackageVersion Include="Testcontainers" Version="3.6.0" />
<PackageVersion Include="Testcontainers.SqlEdge" Version="3.6.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Meziantou.Extensions.Logging.Xunit" Version="1.0.7" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/Domain.UnitTests/Domain.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="JunitXml.TestLogger" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
Expand Down
23 changes: 12 additions & 11 deletions tests/WebApi.IntegrationTests/WebApi.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus"/>
<PackageReference Include="Bogus" />
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions"/>
<PackageReference Include="NSubstitute"/>
<PackageReference Include="Respawn"/>
<PackageReference Include="Testcontainers"/>
<PackageReference Include="Testcontainers.SqlEdge"/>
<PackageReference Include="xunit"/>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="JunitXml.TestLogger" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="Respawn" />
<PackageReference Include="Testcontainers" />
<PackageReference Include="Testcontainers.SqlEdge" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand All @@ -32,7 +33,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\WebApi\WebApi.csproj"/>
<ProjectReference Include="..\..\src\WebApi\WebApi.csproj" />
</ItemGroup>

</Project>

0 comments on commit e2d6b47

Please sign in to comment.