.github/workflows/_unit_tests.yml
name: Run unit tests
on:
workflow_call:
jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Install dotnet global tools
run: |
dotnet tool install --global coverlet.console
dotnet tool install --global dotnet-reportgenerator-globaltool
dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Run tests
run: dotnet test --no-restore --configuration Release --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput='./TestResults/coverage.cobertura.xml'
- name: Attach build result to build artifacts
uses: actions/upload-artifact@v3
with:
name: build-result
path: malimo/obj/Release/net7.0
retention-days: ${{ env.RETENTION_DAYS }}
- name: Generate coverage reports
run: reportgenerator "-reports:malimo.Tests/TestResults/*.xml;malimo.Acceptance.Tests/TestResults/*.xml" \
"-targetdir:report" \
"-reporttypes:Html;lcov" \
"-title:malimo"
- name: Attach coverage reports to build artifacts
uses: actions/upload-artifact@v3
with:
name: coverage-reports
path: report
retention-days: ${{ env.RETENTION_DAYS }}
- name: Generate feature documentation
run: |
livingdoc test-assembly malimo.Acceptance.Tests.dll -t TestExecution.json
mv LivingDoc.html FeatureDocumentation.html
working-directory: malimo.Acceptance.Tests/bin/Release/net7.0
- name: Attach feature documentation to build artifacts
uses: actions/upload-artifact@v3
with:
name: FeatureDocumentation
path: malimo.Acceptance.Tests/bin/Release/net7.0/FeatureDocumentation.html