Testing/Run-BCTests.ps1

function Run-BCTests
{
    Param(
        [Parameter(Mandatory=$false)]
        [string]$ResultPath = '',
        [Parameter(Mandatory=$false)]
        [string]$ContainerName = (Get-ContainerFromLaunchJson),
        # Name of test suite to run
        [Parameter(Mandatory=$false)]
        [string]
        $TestSuite = 'DEFAULT',
        [Parameter(Mandatory=$false)]
        [PSCredential]$Credential = (New-CredentialFromEnvironmentJson),
        [Parameter(Mandatory=$false)]
        [switch]$DoNotPrepTestSuite
    )

    if ((Get-IsALRepo) -and ($ContainerName -eq '')) {
        $ContainerName = (Split-Path (Get-Location) -Leaf)
    }

    if ($ResultPath -ne '') {
        if (Test-Path $ResultPath) {
            Remove-Item $ResultPath
        }
    }

    if ($ContainerName -ne '') {
        Write-Host -ForegroundColor Green "Running tests for $ContainerName"
    }
    
    if (!($DoNotPrepTestSuite.IsPresent)) {
        Get-TestCodeunitsInContainer -ContainerName $ContainerName -TestSuite $TestSuite -Credential $Credential
    }

    Write-Host 'Executing tests in client'

    Run-TestsInNavContainer -containerName $ContainerName -credential $Credential -XUnitResultFileName "C:\ProgramData\NavContainerHelper\Extensions\$ContainerName\my\Results.xml" -detailed -testSuite $TestSuite

    if ($ResultPath -ne '') {
        Copy-Item "C:\ProgramData\NavContainerHelper\Extensions\$ContainerName\my\Results.xml" $ResultPath -Force
    }
}

Export-ModuleMember -Function Run-BCTests