Skip to content

Introducing TestType filter #3959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 9 additions & 2 deletions AppHandling/Get-TestsFromNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
If your container is running AAD authentication, you need to specify an accesstoken for the user specified in credential
.Parameter testSuite
Name of test suite to get. Default is DEFAULT.
.Parameter ExtensionId
Specify an extensionId to get all tests in the app.
.Parameter testType
Specify the type of tests to get. Get all tests if not specified.
.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
Expand Down Expand Up @@ -66,6 +70,8 @@ function Get-TestsFromBcContainer {
[Parameter(Mandatory=$false)]
[string] $testCodeunitRange = "",
[string] $extensionId = "",
[Parameter(Mandatory=$false)]
[string] $testType = "",
[array] $disabledTests = @(),
[Parameter(Mandatory=$false)]
[int] $testPage,
Expand Down Expand Up @@ -180,7 +186,7 @@ try {
}
} -argumentList "01:00:00"

$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh ($version.Major -ge 26) -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $testCodeunitRange, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests)
$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh ($version.Major -ge 26) -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $testCodeunitRange, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $culture, $timezone, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $testType, $disabledtests)

$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) {
Expand Down Expand Up @@ -238,6 +244,7 @@ try {
-TestCodeunit $testCodeunit `
-testCodeunitRange $testCodeunitRange `
-ExtensionId $extensionId `
-TestType $testType `
-DisabledTests $disabledtests `
-testPage $testPage `
-debugMode:$debugMode `
Expand All @@ -259,7 +266,7 @@ try {
}
}

} -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
} -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, $testType, $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
30 changes: 30 additions & 0 deletions AppHandling/PsTestFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ function Set-ExtensionId
$ClientContext.SaveValue($extensionIdControl, $ExtensionId)
}

function Set-TestType
(
[ValidateSet('UnitTest','IntegrationTest','Uncategorized')]
[string] $TestType,
[ClientContext] $ClientContext,
[switch] $debugMode,
$Form
)
{
if ($debugMode) {
Write-Host "Setting Test Type $TestType"
}

$TypeValues = @{
UnitTest = 1
IntegrationTest = 2
Uncategorized = 3
}
$testTypeControl = $ClientContext.GetControlByName($Form, "TestType")
$ClientContext.SaveValue($testTypeControl, $TypeValues[$TestType])
}

function Set-TestCodeunitRange
(
[string] $testCodeunitRange,
Expand Down Expand Up @@ -333,6 +355,7 @@ function Get-Tests {
[string] $testCodeunit = "*",
[string] $testCodeunitRange = "",
[string] $extensionId = "",
[string] $testType = "",
[string] $testRunnerCodeunitId = "",
[array] $disabledtests = @(),
[switch] $debugMode,
Expand Down Expand Up @@ -373,6 +396,9 @@ function Get-Tests {

if ($testPage -eq 130455) {
Set-ExtensionId -ExtensionId $extensionId -Form $form -ClientContext $clientContext -debugMode:$debugMode
if (![string]::IsNullOrEmpty($testType)) {
Set-TestType -TestType $testType -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
Expand Down Expand Up @@ -525,6 +551,7 @@ function Run-Tests {
[string] $testGroup = "*",
[string] $testFunction = "*",
[string] $extensionId = "",
[string] $testType = "",
[string] $appName = "",
[string] $testRunnerCodeunitId,
[array] $disabledtests = @(),
Expand Down Expand Up @@ -589,6 +616,9 @@ function Run-Tests {

if ($testPage -eq 130455) {
Set-ExtensionId -ExtensionId $extensionId -Form $form -ClientContext $clientContext -debugMode:$debugMode
if (![string]::IsNullOrEmpty($testType)) {
Set-TestType -TestType $testType -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
Expand Down
10 changes: 8 additions & 2 deletions AppHandling/Run-TestsInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
Name of test function to run. Wildcards (? and *) are supported. Default is *.
.Parameter ExtensionId
Specifying an extensionId causes the test tool to run all tests in the app with this app id.
.Parameter testType
Specify the type of tests to run. This is used to filter the tests that are run.
.Parameter appName
The app name of then extension with id extensionId.
.Parameter TestRunnerCodeunitId
Expand Down Expand Up @@ -113,6 +115,8 @@ function Run-TestsInBcContainer {
[Parameter(Mandatory=$false)]
[string] $testFunction = "*",
[string] $extensionId = "",
[Parameter(Mandatory=$false)]
[string] $testType = "",
[string] $appName = "",
[string] $testRunnerCodeunitId = "",
[array] $disabledTests = @(),
Expand Down Expand Up @@ -396,6 +400,7 @@ try {
-TestCodeunitRange $testCodeunitRange `
-TestFunction $testFunction `
-ExtensionId $extensionId `
-TestType $testType `
-appName $appName `
-TestRunnerCodeunitId $testRunnerCodeunitId `
-DisabledTests $disabledtests `
Expand Down Expand Up @@ -438,7 +443,7 @@ try {
}
}

$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh ($version.Major -ge 26) -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [System.Management.Automation.PSCredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testCodeunitRange, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [string] $JUnitResultFileName, [bool] $AppendToJUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [string] $GitHubActions, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $appName, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests)
$result = Invoke-ScriptInBcContainer -containerName $containerName -usePwsh ($version.Major -ge 26) -scriptBlock { Param([string] $tenant, [string] $companyName, [string] $profile, [System.Management.Automation.PSCredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testCodeunitRange, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [string] $JUnitResultFileName, [bool] $AppendToJUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [string] $GitHubActions, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $testType, $appName, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests)

$newtonSoftDllPath = "C:\Program Files\Microsoft Dynamics NAV\*\Service\Management\Newtonsoft.Json.dll"
if (!(Test-Path $newtonSoftDllPath)) {
Expand Down Expand Up @@ -519,6 +524,7 @@ try {
-TestCodeunitRange $testCodeunitRange `
-TestFunction $testFunction `
-ExtensionId $extensionId `
-TestType $testType `
-appName $appName `
-TestRunnerCodeunitId $testRunnerCodeunitId `
-DisabledTests $disabledtests `
Expand Down Expand Up @@ -546,7 +552,7 @@ try {
}
}

} -argumentList $tenant, $companyName, $profile, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testCodeunitRange, $testFunction, (Get-BcContainerPath -containerName $containerName -Path $PsTestFunctionsPath), (Get-BCContainerPath -containerName $containerName -path $ClientContextPath), $containerXUnitResultFileName, $AppendToXUnitResultFile, $containerJUnitResultFileName, $AppendToJUnitResultFile, $ReRun, $AzureDevOps, $GitHubActions, $detailed, $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $appName, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests.IsPresent
} -argumentList $tenant, $companyName, $profile, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testCodeunitRange, $testFunction, (Get-BcContainerPath -containerName $containerName -Path $PsTestFunctionsPath), (Get-BCContainerPath -containerName $containerName -path $ClientContextPath), $containerXUnitResultFileName, $AppendToXUnitResultFile, $containerJUnitResultFileName, $AppendToJUnitResultFile, $ReRun, $AzureDevOps, $GitHubActions, $detailed, $interactionTimeout, $testPage, $version, $culture, $timezone, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $testType, $appName, $testRunnerCodeunitId, $disabledtests, $renewClientContextBetweenTests.IsPresent
}
if ($result -is [array]) {
0..($result.Count-2) | % { Write-Host $result[$_] }
Expand Down
1 change: 1 addition & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6.1.7
Issue 3952 Get-AlLanguageExtensionFromArtifacts fails on new BC artifacts
Add support for TestType field when running tests

6.1.6
Added a new outcome to failOn = newWarning. For BcContainerHelper it will work as error - in AL-Go for GitHub it will have a meaning.
Expand Down