Add unit tests with CI/CD automation and comprehensive test reporting #4
This file contains hidden or 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
| name: Unit Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore http.sln | |
| - name: Build | |
| run: dotnet build http.sln --no-restore --configuration Release | |
| - name: Run tests | |
| run: dotnet test http.Tests/http.Tests.csproj --no-build --configuration Release --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage" --results-directory ./TestResults | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: TestResults/**/*.trx | |
| retention-days: 30 | |
| - name: Upload coverage results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-results | |
| path: TestResults/**/coverage.cobertura.xml | |
| retention-days: 30 |