Fleid / asa.unittest

Azure Stream Analytics unit testing solution (fixture and script)
MIT License
3 stars 0 forks source link

Retrieve Test Results #11

Open soniachan opened 4 years ago

soniachan commented 4 years ago

How can we retrieve the unit test test results (*.xml)? There are no test reports in 3_assert folder after test execution.

Fleid commented 4 years ago

Hi @soniachan, at the moment the results are generated as a .txt file in each test case folder. The file is empty if the test is correct, it will contain the diff between execution and expected otherwise:


InputObject                                   SideIndicator
-----------                                   -------------
    "avg_temperature_t5": 28.8366922041976,   =>
    "avg_temperature_t5": 28.836692209941976, <=

I'm open to generating another format if need be?

soniachan commented 4 years ago

Hi @Fleid

I am looking for ways to display the test case results in bamboo build. Currently I can only workaround by invoking pester with another powershell script running the unit test. However, test cases are not displayed in bamboo with this approach.

.\runPesterTests.ps1

$files = Get-ChildItem -Path $PSScriptRoot -Include *.Tests -Recurse
foreach ($file in $files) {
    $test_folder = $file.Name
    $pester_xml = ".\$test_folder\test_output_xml.xml"
    $result = Invoke-Pester -Script ".\$test_folder\$test_folder.ps1" -OutputFile $pester_xml -OutputFormat NUnitXml

    if ($result.FailedCount -gt 0) {
        Write-Error "$test_folder $($result.FailedCount) tests did not pass!"
    }
}

$test_folder.ps1

$asaProjectName = "ASAHelloWorld"
$unittestFolder = "$asaProjectName.Tests"

# set solutionPath to hub_realtime_analytics\azure\stream_analytic
$solutionPath = (get-item $PSScriptRoot).parent.fullname

describe 'ASAHelloWorld' {

  it 'unit-test' {
    New-AutProject -installPath $solutionPath\$unittestFolder -verbose
    Start-AutRun -solutionPath $solutionPath -asaProjectName $asaProjectName -verbose
  }

}