From a3b2bf0043fe26b0ce64be178ef6c3e6bddd39af Mon Sep 17 00:00:00 2001 From: The Dumb Date: Tue, 26 Mar 2024 08:33:51 +0100 Subject: [PATCH] #3441: Add support for "TestCodeunitRangeFilter" field --- AppHandling/Get-TestsFromNavContainer.ps1 | 9 ++++++++ AppHandling/PsTestFunctions.ps1 | 25 +++++++++++++++++++++++ AppHandling/Run-TestsInNavContainer.ps1 | 9 ++++++++ 3 files changed, 43 insertions(+) diff --git a/AppHandling/Get-TestsFromNavContainer.ps1 b/AppHandling/Get-TestsFromNavContainer.ps1 index d1b9c0f2d..1d8c05339 100644 --- a/AppHandling/Get-TestsFromNavContainer.ps1 +++ b/AppHandling/Get-TestsFromNavContainer.ps1 @@ -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 @@ -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)] diff --git a/AppHandling/PsTestFunctions.ps1 b/AppHandling/PsTestFunctions.ps1 index f7aab73ba..f1d7327a2 100644 --- a/AppHandling/PsTestFunctions.ps1 +++ b/AppHandling/PsTestFunctions.ps1 @@ -101,6 +101,27 @@ function Set-ExtensionId $ClientContext.SaveValue($extensionIdControl, $ExtensionId) } +function Set-TestCodeunitRange +( + [string] $testCodeunitRange, + [ClientContext] $ClientContext, + [switch] $debugMode, + $Form +) { + if (!$testCodeunitRange) { return } + if ($testCodeunitRange = "*") { $testCodeunitRange = "" } + + 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, @@ -304,6 +325,7 @@ function Get-Tests { [int] $testPage = 130409, [string] $testSuite = "DEFAULT", [string] $testCodeunit = "*", + [string] $testCodeunitRange = "*", [string] $extensionId = "", [string] $testRunnerCodeunitId = "", [array] $disabledtests = @(), @@ -345,6 +367,7 @@ function Get-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')) @@ -492,6 +515,7 @@ function Run-Tests { [int] $testPage = 130409, [string] $testSuite = "DEFAULT", [string] $testCodeunit = "*", + [string] $testCodeunitRange = "*", [string] $testGroup = "*", [string] $testFunction = "*", [string] $extensionId = "", @@ -558,6 +582,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')) diff --git a/AppHandling/Run-TestsInNavContainer.ps1 b/AppHandling/Run-TestsInNavContainer.ps1 index c26eb27b4..3a840d340 100644 --- a/AppHandling/Run-TestsInNavContainer.ps1 +++ b/AppHandling/Run-TestsInNavContainer.ps1 @@ -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 @@ -330,6 +337,7 @@ try { -TestSuite $testSuite ` -TestGroup $testGroup ` -TestCodeunit $testCodeunit ` + -TestCodeunitRange $testCodeunitRange ` -TestFunction $testFunction ` -ExtensionId $extensionId ` -TestRunnerCodeunitId $testRunnerCodeunitId ` @@ -452,6 +460,7 @@ try { -TestSuite $testSuite ` -TestGroup $testGroup ` -TestCodeunit $testCodeunit ` + -TestCodeunitRange $testCodeunitRange ` -TestFunction $testFunction ` -ExtensionId $extensionId ` -TestRunnerCodeunitId $testRunnerCodeunitId `