Testing/Invoke-BCTest.ps1
<# .synopsis Executes tests in a container .description Executes tests in a container for a specific test suite and optionally a specific codeunit and method .parameter ResultPath Path where the test results should be provided in .parameter ContainerName Container to be used. Can be provided in the settings.json .parameter TestSuite Optional to define the test suite to be used. "DEFAULT" will be used, if not specified .parameter TestCodeunit Optional codeunit to be tested. If not specified, all found test codeunits will be executed .parameter TestMethod Optional method to be tested. If not specific, all found methods in the test codeunit or all test codeunits will be executed .parameter Credential Optional credentials to access the container NAV/BC Version. Will be read from settings.json if not specified .example Invoke-BCTest -ResultPath "C:\" -ContainerName test #> function Invoke-BCTest { Param( [Parameter(Mandatory=$false)] [string]$ResultPath = '', [Parameter(Mandatory=$false)] [string]$ContainerName, # Name of test suite to run [Parameter(Mandatory=$false)] [string] $TestSuite = 'DEFAULT', # Number of test codeunit to run [Parameter(Mandatory=$false)] [string] $TestCodeunit ='*', # Name of test method to run [Parameter(Mandatory=$false)] [string] $TestMethod = '*', [Parameter(Mandatory=$false)] [PSCredential]$Credential = (Get-CredentialFromEnvironmentJson) ) $ContainerName = Get-NewContainerName -SourcePath (Get-Location) -ContainerName $ContainerName if ($ResultPath -ne '') { if (!(Test-Path $ResultPath)) { New-Item $ResultPath -ItemType Directory } } $TestCompanyName = Get-ContainerCompanyToTest -ContainerName $ContainerName Write-Output "Run tests in container $ContainerName, suite $TestSuite, codeunit $TestCodeunit, method $TestMethod" Run-TestsInBcContainer -containerName $ContainerName -credential $Credential -XUnitResultFileName "C:\ProgramData\BcContainerHelper\Extensions\$ContainerName\my\Results.xml" -detailed -testSuite $TestSuite -testCodeunit $TestCodeunit -testFunction $TestMethod -returnTrueIfAllPassed -AzureDevOps error -companyName $TestCompanyName if ($ResultPath -ne '') { Write-Output "Copying results to publishing folder ($ResultPath)" Copy-Item "C:\ProgramData\BcContainerHelper\Extensions\$ContainerName\my\Results.xml" $ResultPath -Force } } Export-ModuleMember -Function Invoke-BCTest |