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 committed Mar 26, 2024
1 parent f578432 commit a3b2bf0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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 comment has been minimized.

Copy link
@freddydk

freddydk Mar 26, 2024

What is the command-line-testtool?
Please specify what the default is (must be empty, thus ignored)

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
25 changes: 25 additions & 0 deletions AppHandling/PsTestFunctions.ps1
Expand Up @@ -101,6 +101,27 @@ function Set-ExtensionId
$ClientContext.SaveValue($extensionIdControl, $ExtensionId)
}

function Set-TestCodeunitRange
(
[string] $testCodeunitRange,
[ClientContext] $ClientContext,
[switch] $debugMode,
$Form
) {
if (!$testCodeunitRange) { return }

This comment has been minimized.

Copy link
@freddydk

freddydk Mar 26, 2024

This implementation will change the default flow of get and run-tests and always set the value.
I don't like that.
The default value of testCodeunitRange should be empty and it should never set anything in the control unless a value is provided.
Then, I guess you would have to say '*' in order to clear the field, which is fine.

This comment has been minimized.

Copy link
@Thomas-Torggler-EOS

Thomas-Torggler-EOS Mar 26, 2024

Author Collaborator

Yeah, I know. This is still WIP, doesn't even work at the moment. I actually already changed it, still working on it though.

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,
Expand Down Expand Up @@ -304,6 +325,7 @@ function Get-Tests {
[int] $testPage = 130409,
[string] $testSuite = "DEFAULT",
[string] $testCodeunit = "*",
[string] $testCodeunitRange = "*",
[string] $extensionId = "",
[string] $testRunnerCodeunitId = "",
[array] $disabledtests = @(),
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -492,6 +515,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 +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'))
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 a3b2bf0

Please sign in to comment.