Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Actions/AnalyzeTests/AnalyzeTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ switch ($testType) {
-baseLinePath $bcptBaseLineFile `
-thresholdsPath $bcptThresholdsFile `
-bcptThresholds ($settings.bcptThresholds | ConvertTo-HashTable)
if (-not $testResultsSummaryMD -and (Test-Path -Path $bcptTestResultsFile -PathType Leaf)) {
OutputWarning "BCPT tests were run but produced no results. The BCPT test suite may have failed to start or the test codeunits exited without recording any measurements."
}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new warning annotation block is effectively unreachable: GetBcptSummaryMD only returns an empty/falsey value when the results file does not exist, but this condition requires the file to exist (Test-Path ... -PathType Leaf). If the intention is to surface an empty-results warning annotation, consider keying this check off the parsed BCPT contents (e.g., ReadBcptFile returning an empty hashtable) or emitting the warning from GetBcptSummaryMD when it detects an empty results file.

Copilot uses AI. Check for mistakes.
$testTitle = "Performance test results"
}
'pageScripting' {
Expand Down
6 changes: 5 additions & 1 deletion Actions/AnalyzeTests/TestResultAnalyzer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,13 @@ function GetBcptSummaryMD {
)

$bcpt = ReadBcptFile -bcptTestResultsFile $bcptTestResultsFile
if (-not $bcpt) {
if ($null -eq $bcpt) {
return ''
}
if ($bcpt.Count -eq 0) {
# File exists but contained no log entries - test run produced no output
return "No BCPT results were recorded. The BCPT test suite may have failed to start or the test codeunits exited without recording any measurements.`n`n> Verify that the BCPT suite definition matches the published test codeunit IDs and that the test codeunits are reachable from the test runner."
}
$baseLine = ReadBcptFile -bcptTestResultsFile $baseLinePath
if ($baseLine) {
if ($null -eq $bcptThresholds) {
Expand Down
29 changes: 29 additions & 0 deletions Tests/AnalyzeTests.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@ Describe "AnalyzeTests Action Tests" {
$bcpt."SUITE1"."1".operations."operation2".measurements.Count | should -Be 4
}

It 'Test ReadBcptFile returns null when file does not exist' {
. (Join-Path $scriptRoot '../AL-Go-Helper.ps1')
. (Join-Path $scriptRoot 'TestResultAnalyzer.ps1')
$bcpt = ReadBcptFile -bcptTestResultsFile 'non-existent-file.json'
$bcpt | Should -BeNullOrEmpty
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test description says it verifies ReadBcptFile returns $null when the file is missing, but Should -BeNullOrEmpty would also pass for an empty hashtable/collection. To make the behavior under test explicit (and guard the $null vs empty distinction used by GetBcptSummaryMD), assert specifically that the value is $null.

Suggested change
$bcpt | Should -BeNullOrEmpty
$bcpt | Should -Be $null

Copilot uses AI. Check for mistakes.
}

It 'Test GetBcptSummaryMD returns empty string when file does not exist' {
. (Join-Path $scriptRoot '../AL-Go-Helper.ps1')
. (Join-Path $scriptRoot 'TestResultAnalyzer.ps1')
$md = GetBcptSummaryMD -bcptTestResultsFile 'non-existent-file.json'
$md | Should -Be ''
}

It 'Test GetBcptSummaryMD returns warning message when file exists but contains no entries' {
. (Join-Path $scriptRoot '../AL-Go-Helper.ps1')
. (Join-Path $scriptRoot 'TestResultAnalyzer.ps1')
$emptyResultsFile = Join-Path ([System.IO.Path]::GetTempPath()) "$([GUID]::NewGuid().ToString()).json"
try {
$null | ConvertTo-Json -Depth 99 | Set-Content -Path $emptyResultsFile -Encoding UTF8
$md = GetBcptSummaryMD -bcptTestResultsFile $emptyResultsFile
$md | Should -Not -BeNullOrEmpty
$md | Should -Match 'No BCPT results were recorded'
}
Comment on lines +95 to +107
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “file exists but contains no entries” test writes JSON null to disk. BCPT result files appear to be JSON arrays (your helper uses @(...) | ConvertTo-Json), so an empty-results file would more realistically be [] (empty array). Using an empty array here would better match the real-world format and protect against differences in how ConvertFrom-Json handles null vs [].

Copilot uses AI. Check for mistakes.
finally {
Remove-Item -Path $emptyResultsFile -Force -ErrorAction SilentlyContinue
}
}

It 'Test GetBcptSummaryMD (no baseline)' {
. (Join-Path $scriptRoot '../AL-Go-Helper.ps1')
. (Join-Path $scriptRoot 'TestResultAnalyzer.ps1')
Expand Down
Loading