|
8 | 8 | env: |
9 | 9 | SOLUTION_FILE: ValueMapper/ValueMapper.sln |
10 | 10 | PROJECT_PATH: ValueMapper/ValueMapperCore/ValueMapper.csproj |
11 | | - TEST_RESULTS_PATH: TestResults |
12 | 11 |
|
13 | 12 | jobs: |
14 | 13 | build: |
|
30 | 29 | run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release |
31 | 30 |
|
32 | 31 | - name: "Run tests" |
33 | | - shell: pwsh |
| 32 | + shell: bash |
34 | 33 | run: | |
35 | | - mkdir -p ${{ env.TEST_RESULTS_PATH }} |
36 | | - dotnet test ${{ env.SOLUTION_FILE }} --no-build --configuration Release --logger "trx;LogFileName=test_results.trx" --results-directory ${{ env.TEST_RESULTS_PATH }} |
37 | | - # Continue even if tests fail |
| 34 | + dotnet test ${{ env.SOLUTION_FILE }} --no-build --configuration Release || echo "::warning::Tests failed but we're continuing the workflow" |
| 35 | + # This ensures the step always exits with code 0 (success) |
38 | 36 | exit 0 |
39 | | -
|
40 | | - - name: "Upload test results" |
41 | | - uses: actions/upload-artifact@v3 |
42 | | - if: always() |
43 | | - with: |
44 | | - name: test-results |
45 | | - path: ${{ env.TEST_RESULTS_PATH }} |
46 | | - |
47 | | - - name: "Test Report" |
48 | | - uses: dorny/test-reporter@v1 |
49 | | - if: always() |
50 | | - with: |
51 | | - name: .NET Tests |
52 | | - path: "${{ env.TEST_RESULTS_PATH }}/*.trx" |
53 | | - reporter: dotnet-trx |
54 | | - fail-on-error: false |
55 | | - |
56 | | - - name: "Check for test failures" |
57 | | - shell: pwsh |
58 | | - if: always() |
59 | | - run: | |
60 | | - $trxFiles = Get-ChildItem -Path "${{ env.TEST_RESULTS_PATH }}" -Filter "*.trx" |
61 | | - foreach ($file in $trxFiles) { |
62 | | - $xml = [xml](Get-Content $file.FullName) |
63 | | - $failedTests = $xml.SelectNodes("//UnitTestResult[@outcome='Failed']") |
64 | | - $totalTests = $xml.SelectNodes("//UnitTestResult").Count |
65 | | - $passedTests = $totalTests - $failedTests.Count |
66 | | - |
67 | | - Write-Output "Total Tests: $totalTests" |
68 | | - Write-Output "Passed Tests: $passedTests" |
69 | | - Write-Output "Failed Tests: $($failedTests.Count)" |
70 | | - |
71 | | - if ($failedTests.Count -gt 0) { |
72 | | - Write-Output "::warning::❌ $($failedTests.Count) tests failed out of $totalTests tests" |
73 | | - foreach ($test in $failedTests) { |
74 | | - $testName = $test.testName |
75 | | - Write-Output "::warning::Failed Test: $testName" |
76 | | - } |
77 | | - } else { |
78 | | - Write-Output "::notice::✅ All $totalTests tests passed!" |
79 | | - } |
80 | | - } |
0 commit comments