Testing/Invoke-NAVTestsForAL.ps1
Param( [Parameter(Mandatory=$true,Position=1)] [string]$SourcePath, [Parameter(Mandatory=$true,Position=2)] [string]$OutputPath, [Parameter(Mandatory=$true,Position=3)] $BuildNumber, [Parameter(Mandatory=$false,Position=4)] [string]$ServerInstance = 'ExtensionTesting2018' ) Import-Module 'C:\Tfs\TFS Tools\Tecman.Tfs.Tools.psm1' $AppJsonContent = Get-Content (Join-Path $SourcePath 'app.json') -Raw $AppJson = ConvertFrom-Json $AppJsonContent $AppWithTestsPath = New-ALAppPackageFromGit -SourceFolder $SourcePath -OutputPath $OutputPath Rename-Item -Path $AppWithTestsPath -NewName (Split-Path $AppWithTestsPath -Leaf).Insert(0,'Test-') $AppWithTestsPath = $AppWithTestsPath.Insert($AppWithTestsPath.LastIndexOf('\') + 1,'Test-') #remove the tests folder and test $AppJson.PSObject.Properties.Remove('test') $AppJsonContent = ConvertTo-Json $AppJson Remove-Item (Join-Path $SourcePath 'Tests') -Recurse -Force Remove-Item (Join-Path $SourcePath 'app.json') Add-Content (Join-Path $SourcePath 'app.json') $AppJsonContent New-ALAppPackageFromGit -SourceFolder $SourcePath -OutputPath $OutputPath #prepare the service tier Import-NAVModulesForServerInstance $ServerInstance #remove all non-Microsoft packages Get-NAVAppInfo $ServerInstance | where Publisher -ne Microsoft | foreach {Uninstall-NavApp $ServerInstance -Name $_.Name -Version $_.Version -DoNotSaveData -Force} -ErrorAction SilentlyContinue Get-NAVAppInfo $ServerInstance | where Publisher -ne Microsoft | foreach {Unpublish-NAVApp $ServerInstance -Name $_.Name -Version $_.Version} -ErrorAction SilentlyContinue Sync-NAVTenant $ServerInstance -Mode ForceSync -Force #pulish non-Microsoft packages from the .alpackages folder $DependencyFiles = Get-ChildItem (Join-Path $SourcePath '.alpackages') -Exclude 'Microsoft*' foreach ($DependencyFile in $DependencyFiles) { Publish-NAVApp $ServerInstance -Path $DependencyFile.FullName -SkipVerification Sync-NAVApp $ServerInstance -Path $DependencyFile.FullName Install-NAVApp $ServerInstance -Path $DependencyFile.FullName } #publish the app with the tests Publish-NAVApp $ServerInstance -Path $AppWithTestsPath Sync-NAVApp $ServerInstance -Path $AppWithTestsPath Install-NAVApp $ServerInstance -Path $AppWithTestsPath $ResultPath = "C:\Testing\NAVResults\$BuildNumber.xml" Run-NAVTests -ServerInstance $ServerInstance -ResultPath $ResultPath if (!(Test-Path "C:\Testing\$BuildNumber")) { Create-EmptyDirectory "C:\Testing\$BuildNumber" } Convert-NAVResultsToXUnit -NAVResultsPath $ResultPath -XUnitPath "C:\Testing\$BuildNumber\Results.xml" |