Last active
February 13, 2024 15:12
-
-
Save kkorsakov/fbdfd34ec4c25e2846cc7d0fc341ee1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#запускать так (формат pipeline.xml | |
- task: PowerShell@2 | |
name: "RunTests" | |
inputs: | |
filePath: '$(Pipeline.Workspace)\s\project\Automation\RunTests.ps1' | |
workingDirectory: $(Pipeline.Workspace)\s\project | |
pwsh: true | |
timeoutInMinutes: 6000 | |
- task: PublishTestResults@2 | |
name: "PublishTestResults" | |
inputs: | |
testResultsFormat: 'JUnit' | |
testResultsFiles: '*.xml' | |
searchFolder: $(Pipeline.Workspace)\TestResults | |
mergeTestResults: true | |
failTaskOnFailedTests: false | |
failTaskOnFailureToPublishResults: true | |
failTaskOnMissingResultsFile: true | |
testRunTitle: 'Unit tests' | |
buildPlatform: 'Win64' | |
buildConfiguration: 'Client' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run Automation Tests as usual | |
if ($IsWindows) | |
{ | |
$argstr = "$projectDir\$projectName.uproject -ExecCmds=""automation RunTests"" -TestExit=""Automation Test Queue Empty"" -NullRHI -unattended -nopause -nosplash -Log -ReportExportPath=""$projectDir\..\..\TestResults""" | |
$UED = Start-Process -FilePath "$ue\Engine\Binaries\Win64\UnrealEditor.exe" -ArgumentList $argstr -Wait -NoNewWindow -PassThru | |
} | |
if ($IsLinux) | |
{ | |
$argstr = "$projectDir\$projectName.uproject -ExecCmds=""automation RunTests"" -TestExit=""Automation Test Queue Empty"" -NullRHI -unattended -nopause -nosplash -Log -ReportExportPath=""$projectDir/../../TestResults""" | |
$UED = Start-Process -FilePath "$ue/Engine/Binaries/Linux/UnrealEditor" -ArgumentList $argstr -Wait -NoNewWindow -PassThru | |
} | |
if ($UED.ExitCode -ne 0) | |
{ | |
Write-Output $UED.ExitCode | |
exit 1; | |
} | |
Write-Output "Finished tests" | |
# Read the JSON data from a file | |
$reportContent = Get-Content -Path "$projectDir\..\..\TestResults\index.json" | ConvertFrom-JSON | |
$xml = New-Object System.Xml.XmlDocument | |
$decl = $xml.CreateXmlDeclaration("1.0", $null, $null) | |
$xml.AppendChild($decl) | |
$testsuite = $xml.CreateElement("testsuite") | |
$testsuite.SetAttribute("tests", ($reportContent.succeeded + $reportContent.failed)) | |
$testsuite.SetAttribute("failures", $reportContent.failed) | |
$testsuite.SetAttribute("time", $reportContent.totalDuration) | |
$xml.AppendChild($testsuite) | |
foreach ($test in $reportContent.tests) | |
{ | |
$testcase = $xml.CreateElement("testcase") | |
$testcase.SetAttribute("name", $test.fullTestPath) | |
$testcase.SetAttribute("classname", $test.fullTestPath) | |
$testcase.SetAttribute("status", $test.state) | |
$testsuite.AppendChild($testcase) | |
$outString = "" | |
$errorString = "" | |
foreach ($entry in $test.entries) | |
{ | |
if ($entry.event.type -eq "Info") | |
{ | |
$outString = $outString + "$( $entry.event.message )`r`n" | |
} | |
else | |
{ | |
$errorString = $errorString + "$( $entry.event.message ) in $( $entry.filename.Substring($projectDir.Length).Replace('\','/') ):line $( $entry.lineNumber )`r`n" | |
} | |
} | |
if ($outString.Length -gt 0) | |
{ | |
$systemOut = $xml.CreateElement("system-out") | |
$systemOut.InnerText = $outString | |
$testcase.AppendChild($systemOut) | |
} | |
if ($errorString.Length -gt 0) | |
{ | |
$error = $xml.CreateElement("error") | |
$error.SetAttribute("message", $errorString) | |
$error.SetAttribute("type", "Error") | |
$error.InnerText = $errorString | |
$testcase.AppendChild($error) | |
} | |
} | |
$xml.OuterXml | Set-Content "$projectDir\..\..\TestResults\junit.xml" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment