@@ -30,102 +30,132 @@ jobs:
3030 run : dotnet build tests/SharpGraph.Tests/SharpGraph.Tests.csproj --configuration Debug
3131
3232 - name : Run Tests
33- run : dotnet test tests/SharpGraph.Tests/SharpGraph.Tests.csproj --configuration Debug --no-build --verbosity normal --logger "trx;LogFileName=../../test-results.trx" --logger "console;verbosity=detailed" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=..\..\coverage.cobertura.xml
34-
35- - name : Install Report Generator
36- run : dotnet tool install --global dotnet-reportgenerator-globaltool
33+ run : dotnet test tests/SharpGraph.Tests/SharpGraph.Tests.csproj --configuration Debug --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --logger "console;verbosity=detailed"
3734
3835 - name : Find Coverage Files
3936 shell : pwsh
4037 run : |
41- Write-Host "Looking for coverage files..."
42- Get-ChildItem -Path . -Filter "*.cobertura.xml " -Recurse | ForEach-Object { Write-Host $ _.FullName }
38+ Write-Host "Searching for test result files..."
39+ Get-ChildItem -Path . -Filter "test-results.trx " -Recurse | ForEach-Object { Write-Host "Found TRX: $($ _.FullName)" }
4340
44- - name : Generate Coverage Report
45- shell : pwsh
46- run : |
47- $coverageFile = Get-ChildItem -Path . -Filter "*.cobertura.xml" -Recurse | Select-Object -First 1
48- if ($null -ne $coverageFile) {
49- Write-Host "Found coverage file: $($coverageFile.FullName)"
50- reportgenerator -reports:"$($coverageFile.FullName)" -targetdir:"coverage-report" -reporttypes:"HtmlInline;Markdown"
51- } else {
52- Write-Host "No coverage files found, creating dummy report"
53- New-Item -ItemType Directory -Path "coverage-report" -Force | Out-Null
54- "# Coverage Report`n`nNo coverage data available." | Out-File -FilePath "coverage-report/Summary.md" -Encoding UTF8
55- }
41+ - name : Install Report Generator
42+ run : dotnet tool install --global dotnet-reportgenerator-globaltool
5643
5744 - name : Generate Test Report
5845 if : always()
5946 shell : pwsh
6047 run : |
6148 $trxFile = Get-ChildItem -Path . -Filter "test-results.trx" -Recurse | Select-Object -First 1
62- Write-Host "Looking for TRX file..."
6349
6450 if ($null -ne $trxFile) {
6551 Write-Host "TRX File found: $($trxFile.FullName)"
6652 [xml]$trx = Get-Content $trxFile.FullName
53+
54+ # Extract summary
6755 $passed = [int]$trx.TestRun.ResultSummary.Counters.passed
6856 $failed = [int]$trx.TestRun.ResultSummary.Counters.failed
6957 $total = [int]$trx.TestRun.ResultSummary.Counters.total
7058 $duration = $trx.TestRun.Times.duration
59+ $runDate = Get-Date -Format 'yyyy-MM-dd HH:mm:ss UTC'
7160
7261 Write-Host "Tests - Total: $total, Passed: $passed, Failed: $failed"
7362
7463 New-Item -ItemType Directory -Path "docs" -Force | Out-Null
7564
76- $status = if ($failed -eq 0) { "✅ **All tests passing**" } else { "❌ **Tests failed**" }
77- $runDate = Get-Date -Format 'yyyy-MM-dd HH:mm:ss UTC'
78- $repoUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
79-
80- $report = "# Unit Test Report`n"
81- $report += "`n"
65+ # Build comprehensive report
66+ $report = "# Unit Test Report`n`n"
8267 $report += "**Run Date**: $runDate`n"
8368 $report += "**Branch**: ${{ github.ref_name }}`n"
84- $report += "**Commit**: ${{ github.sha }}`n"
85- $report += "`n"
86- $report += "## Summary`n"
87- $report += "`n"
69+ $report += "**Commit**: ${{ github.sha }}`n`n "
70+
71+ # Summary section
72+ $report += "## Summary`n `n"
8873 $report += "| Metric | Value |`n"
8974 $report += "|--------|-------|`n"
9075 $report += "| Total Tests | $total |`n"
91- $report += "| ✅ Passed | $passed |`n"
92- $report += "| ❌ Failed | $failed |`n"
93- $report += "| ⏱️ Duration | $duration |`n"
94- $report += "`n"
95- $report += "## Status`n"
96- $report += "`n"
97- $report += "$status`n"
98- $report += "`n"
99- $report += "## Test Categories`n"
100- $report += "`n"
101- $report += "- Lexer Tests - GraphQL tokenization and parsing`n"
102- $report += "- Filtering Tests - Query filtering, sorting, pagination`n"
103- $report += "- Storage Tests - Data persistence and indexing`n"
104- $report += "- Index Tests - BTree and Hash index operations`n"
105- $report += "- Mutation Tests - GraphQL mutation handling`n"
106- $report += "- Parsing Tests - GraphQL schema and query parsing`n"
107- $report += "`n"
76+ $report += "| Passed | $passed |`n"
77+ $report += "| Failed | $failed |`n"
78+ $report += "| Duration | $duration |`n"
79+ $report += "| Pass Rate | $(if ($total -gt 0) { ([math]::Round(($passed/$total)*100, 2)) } else { 0 })% |`n`n"
80+
81+ # Status
82+ $status = if ($failed -eq 0) { "**Status**: ✅ All tests passing" } else { "**Status**: ❌ Tests failed" }
83+ $report += "$status`n`n"
84+
85+ # Parse all tests by category
86+ $categories = @{}
87+ if ($null -ne $trx.TestRun.Results) {
88+ $trx.TestRun.Results.UnitTestResult | ForEach-Object {
89+ $testName = $_.testName
90+ $outcome = $_.outcome
91+ $duration = $_.duration
92+
93+ # Extract category from test name
94+ $parts = $testName -split '\.'
95+ if ($parts.Count -gt 2) {
96+ $category = $parts[-2]
97+ } else {
98+ $category = "Other"
99+ }
100+
101+ if (-not $categories.ContainsKey($category)) {
102+ $categories[$category] = @{ Passed = 0; Failed = 0; Tests = @() }
103+ }
104+
105+ if ($outcome -eq "Passed") {
106+ $categories[$category].Passed++
107+ } else {
108+ $categories[$category].Failed++
109+ }
110+
111+ $categories[$category].Tests += @{
112+ Name = $testName
113+ Outcome = $outcome
114+ Duration = $duration
115+ }
116+ }
117+ }
108118
109- # Check if coverage report exists
110- $coverageMd = Get-ChildItem -Path "coverage-report" -Filter "Summary.md" -Recurse | Select-Object -First 1
111- if ($null -ne $coverageMd) {
112- $report += "## Code Coverage`n"
113- $report += "`n"
114- $report += "[View Coverage Report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts)`n"
115- $report += "`n"
119+ # Write test results by category
120+ if ($categories.Count -gt 0) {
121+ $report += "## Test Results by Category`n`n"
122+
123+ foreach ($cat in ($categories.Keys | Sort-Object)) {
124+ $data = $categories[$cat]
125+ $total_cat = $data.Passed + $data.Failed
126+ $report += "### $cat`n`n"
127+ $report += "**Status**: $($data.Passed)/$total_cat passed`n`n"
128+
129+ # List failed tests first
130+ $failedTests = $data.Tests | Where-Object { $_.Outcome -ne "Passed" }
131+ if ($failedTests.Count -gt 0) {
132+ $report += "#### Failed Tests`n`n"
133+ $failedTests | ForEach-Object {
134+ $report += "- ❌ $($_.Name)`n"
135+ $report += " - Duration: $($_.Duration)`n"
136+ }
137+ $report += "`n"
138+ }
139+
140+ # Summary for passed tests
141+ $passedCount = ($data.Tests | Where-Object { $_.Outcome -eq "Passed" }).Count
142+ if ($passedCount -gt 0) {
143+ $report += "- ✅ $passedCount tests passed`n"
144+ }
145+ $report += "`n"
146+ }
116147 }
117148
118- $report += "---`n"
119- $report += "`n"
120- $report += "[View Full Test Results]($repoUrl )`n"
149+ # Footer
150+ $report += "---`n `n"
151+ $report += "[View Full Test Results](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} )`n"
121152
122153 $report | Out-File -FilePath "docs/unit-test-report.md" -Encoding UTF8 -Force
123154
124155 Write-Host "Report saved to docs/unit-test-report.md"
125- Write-Host "File exists : $(Test-Path 'docs/unit-test-report.md')"
156+ Write-Host "File size : $((Get-Item 'docs/unit-test-report.md').Length) bytes "
126157 } else {
127158 Write-Host "ERROR: TRX file not found!"
128- Get-ChildItem -Path . -Recurse -Filter "*.trx" | ForEach-Object { Write-Host $_.FullName }
129159 }
130160
131161 - name : Commit Test Report
@@ -145,14 +175,6 @@ jobs:
145175 path : ' **/test-results.trx'
146176 retention-days : 30
147177
148- - name : Upload Coverage Report
149- uses : actions/upload-artifact@v4
150- if : always()
151- with :
152- name : coverage-report
153- path : coverage-report/
154- retention-days : 30
155-
156178 - name : Upload Test Report
157179 uses : actions/upload-artifact@v4
158180 if : always()
0 commit comments