I am running a set of parameterized integration tests using NUnit / C# in Azure DevOps (yaml pipelines)
The tests are parameterized at class level with
[TestFixture(param1, param2, param3)]
[TestFixture(param1, param2, param3)]
... more test fixtures
public class CheckOutput (param1, param2, param3){
[Test]
public void check_something(){
do something with the parameters
}
}
The test results xml file contains the following:
<test-case
name = "check_something"
fullname = "A.B.C.CheckOutput(param1,param2, param3).check_something"
methodname = "check_something"
classname = "A.B.C.CheckOutput"
</test-case>
The test results contains the full name, however in Azure DevOps only the name is reported.
Is it possible to have the full name which includes all of the parameters reported in Azure DevOps test results as if there is a test failure then it would be helpful to know which set of parameters caused the failure(s)
I have looked at the Publish Test Results Task page but there doesn't seem to be anything obvious there.
We managed to get full test names in Azure DevOps report by including Powershell task between test execution task and "Publish Test Result" task. Azure DevOps looks only into "name" attribute of NUnit tests, so the task's purpose is to get "fullname" value and place it into the "name" attribute:
- task: PowerShell@2
displayName: Update test names in test result file
inputs:
targetType: 'inline'
script: |
$testLog = [xml](Get-Content -Encoding 'UTF8' $(TestResultFile));
$nodes = $testLog.SelectNodes("//test-case");
foreach ($node in $nodes){ $node.Attributes["name"].Value = $node.Attributes["fullname"].Value }
$testLog.Save($(TestResultFile))
We have only one test assembly (and thus one test result xml defined in $(TestResultFile) variable) so if you have more of them, you'll need to run this task for each test result file.
NOTE: this probably won't work for tests that have custom name set via NUnit's TestCaseData.SetName() method.