Skip to content

Commit

Permalink
microsoft#3441: Add support for "TestCodeunitRangeFilter" field
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Torggler-EOS authored and hemisphera committed Apr 16, 2024
1 parent f157a40 commit 76be583
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
12 changes: 11 additions & 1 deletion AppHandling/Get-TestsFromNavContainer.ps1
Expand Up @@ -20,6 +20,13 @@
Name of test suite to get. Default is DEFAULT.
.Parameter testCodeunit
Name or ID of test codeunit to get. Wildcards (? and *) are supported. Default is *.
This parameter will not populate the test suite with the specified codeunit. This is used as a filter on the tests that are already present
(or otherwise loaded) in the suite.
This is not to be confused with -testCodeunitRange.
.Parameter testCodeunitRange
A BC-compatible filter string to use for loading test codeunits (similar to -extensionId). This is not to be confused with -testCodeunit.
If you set this parameter to '*', all test codeunits will be loaded.
This might not work on all versions of BC and only works when using the command-line-testtool.
.Parameter testPage
ID of the test page to use. Default for 15.x containers is 130455. Default for 14.x containers and earlier is 130409.
.Parameter culture
Expand Down Expand Up @@ -56,6 +63,8 @@ function Get-TestsFromBcContainer {
[string] $testSuite = "DEFAULT",
[Parameter(Mandatory=$false)]
[string] $testCodeunit = "*",
[Parameter(Mandatory=$false)]
[string] $testCodeunitRange,
[string] $extensionId = "",
[array] $disabledTests = @(),
[Parameter(Mandatory=$false)]
Expand Down Expand Up @@ -227,6 +236,7 @@ try {
Get-Tests -clientContext $clientContext `
-TestSuite $testSuite `
-TestCodeunit $testCodeunit `
-testCodeunitRange $testCodeunitRange `
-ExtensionId $extensionId `
-DisabledTests $disabledtests `
-testPage $testPage `
Expand All @@ -249,7 +259,7 @@ try {
}
}

} -argumentList $tenant, $companyName, $profile, $credential, $accessToken, $testSuite, $testCodeunit, (Get-BCContainerPath -containerName $containerName -path $PsTestFunctionsPath), (Get-BCContainerPath -containerName $containerName -path $ClientContextPath), $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests
} -argumentList $tenant, $companyName, $profile, $credential, $accessToken, $testSuite, $testCodeunit, $testCodeunitRange, (Get-BCContainerPath -containerName $containerName -path $PsTestFunctionsPath), (Get-BCContainerPath -containerName $containerName -path $ClientContextPath), $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests

# When Invoke-ScriptInContainer is running as non-administrator - Write-Host (like license warnings) are send to the output
# If the output is an array - grab the last item.
Expand Down
28 changes: 28 additions & 0 deletions AppHandling/PsTestFunctions.ps1
Expand Up @@ -101,6 +101,28 @@ function Set-ExtensionId
$ClientContext.SaveValue($extensionIdControl, $ExtensionId)
}

function Set-TestCodeunitRange
(
[string] $testCodeunitRange,
[ClientContext] $ClientContext,
[switch] $debugMode,
$Form
) {
Write-Host "Setting test codeunit range '$testCodeunitRange'"
if (!$testCodeunitRange) { return }
if ($testCodeunitRange = "*") { $testCodeunitRange = "0.." }

if ($debugMode) {
Write-Host "Setting test codeunit range '$testCodeunitRange'"
}
$testCodeunitRangeControl = $ClientContext.GetControlByName($Form, "TestCodeunitRangeFilter")
if ($null -eq $testCodeunitRangeControl) {
if ($debugMode) { Write-Host "Test codeunit range control not found on test page" }
return
}
$ClientContext.SaveValue($testCodeunitRangeControl, $testCodeunitRange)
}

function Set-TestRunnerCodeunitId
(
[string] $testRunnerCodeunitId,
Expand Down Expand Up @@ -304,6 +326,7 @@ function Get-Tests {
[int] $testPage = 130409,
[string] $testSuite = "DEFAULT",
[string] $testCodeunit = "*",
[string] $testCodeunitRange,
[string] $extensionId = "",
[string] $testRunnerCodeunitId = "",
[array] $disabledtests = @(),
Expand Down Expand Up @@ -343,8 +366,11 @@ function Get-Tests {
$suiteControl = $clientContext.GetControlByName($form, "CurrentSuiteName")
$clientContext.SaveValue($suiteControl, $testSuite)

Write-Host ">>$testPage"
Write-Host ">>$testCodeunitRange"
if ($testPage -eq 130455) {
Set-ExtensionId -ExtensionId $extensionId -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-TestCodeunitRange -testCodeunitRange $testCodeunitRange -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-TestRunnerCodeunitId -TestRunnerCodeunitId $testRunnerCodeunitId -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-RunFalseOnDisabledTests -DisabledTests $DisabledTests -Form $form -ClientContext $clientContext -debugMode:$debugMode
$clientContext.InvokeAction($clientContext.GetActionByName($form, 'ClearTestResults'))
Expand Down Expand Up @@ -492,6 +518,7 @@ function Run-Tests {
[int] $testPage = 130409,
[string] $testSuite = "DEFAULT",
[string] $testCodeunit = "*",
[string] $testCodeunitRange,
[string] $testGroup = "*",
[string] $testFunction = "*",
[string] $extensionId = "",
Expand Down Expand Up @@ -558,6 +585,7 @@ function Run-Tests {

if ($testPage -eq 130455) {
Set-ExtensionId -ExtensionId $extensionId -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-TestCodeunitRange -testCodeunitRange $testCodeunitRange -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-TestRunnerCodeunitId -TestRunnerCodeunitId $testRunnerCodeunitId -Form $form -ClientContext $clientContext -debugMode:$debugMode
Set-RunFalseOnDisabledTests -DisabledTests $DisabledTests -Form $form -ClientContext $clientContext -debugMode:$debugMode
$clientContext.InvokeAction($clientContext.GetActionByName($form, 'ClearTestResults'))
Expand Down
9 changes: 9 additions & 0 deletions AppHandling/Run-TestsInNavContainer.ps1
Expand Up @@ -22,6 +22,13 @@
Only supported in 14.x containers or older. Name of test group to run. Wildcards (? and *) are supported. Default is *.
.Parameter testCodeunit
Name or ID of test codeunit to run. Wildcards (? and *) are supported. Default is *.
This parameter will not populate the test suite with the specified codeunit. This is used as a filter on the tests that are already present
(or otherwise loaded) in the suite.
This is not to be confused with -testCodeunitRange.
.Parameter testCodeunitRange
A BC-compatible filter string to use for loading test codeunits (similar to -extensionId). This is not to be confused with -testCodeunit.
If you set this parameter to '*', all test codeunits will be loaded.
This might not work on all versions of BC and only works when using the command-line-testtool.
.Parameter testFunction
Name of test function to run. Wildcards (? and *) are supported. Default is *.
.Parameter ExtensionId
Expand Down Expand Up @@ -330,6 +337,7 @@ try {
-TestSuite $testSuite `
-TestGroup $testGroup `
-TestCodeunit $testCodeunit `
-TestCodeunitRange $testCodeunitRange `
-TestFunction $testFunction `
-ExtensionId $extensionId `
-TestRunnerCodeunitId $testRunnerCodeunitId `
Expand Down Expand Up @@ -452,6 +460,7 @@ try {
-TestSuite $testSuite `
-TestGroup $testGroup `
-TestCodeunit $testCodeunit `
-TestCodeunitRange $testCodeunitRange `
-TestFunction $testFunction `
-ExtensionId $extensionId `
-TestRunnerCodeunitId $testRunnerCodeunitId `
Expand Down

0 comments on commit 76be583

Please sign in to comment.