Skip to content

Commit d8f4335

Browse files
jonathanpeppersgrendello
authored andcommitted
[bcl-tests] fix NUnit test result files for Jenkins (#2094)
* [Xamarin.Android.NUnitLite] don't omit empty <categories /> Context: https://jenkins.mono-project.com/job/xamarin-android-pr-builder/3806 Context: mono/NUnitLite#12 Our on-device tests don't appear to be reporting properly in Jenkins: INFO: Starting to record. INFO: Processing NUnit-2.x (default) INFO: [NUnit-2.x (default)] - 16 test report file(s) were found with the pattern 'xamarin-android/TestResult-*.xml' relative to '/Users/builder/jenkins/workspace/xamarin-android-pr-builder' for the testing framework 'NUnit-2.x (default)'. WARNING: The file '/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.nunit-Debug.xml' is an invalid file. WARNING: At line 7 of file:/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.nunit-Debug.xml:cvc-complex-type.2.4.b: The content of element 'categories' is not complete. One of '{category}' is expected. Followed by thousands of similar warnings... Apparently the latest Jenkins plugin for NUnit tests is more strict about the test result format. We can add the patch from @akoeplinger to prevent these empty `<categories />` from being omitted. Hopefully this fixes it! * [TestRunner.xUnit] reorder when <properties /> emitted Context: https://jenkins.mono-project.com/job/xamarin-android-pr-builder/3806 Context: xunit/xunit#1797 Our on-device XUnit tests don't appear to be reporting properly in Jenkins: WARNING: The result file '/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.nunit-Debug.xml' for the metric 'NUnit' is not valid. The result file has been skipped. WARNING: The file '/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.xunit-Debug.xml' is an invalid file. WARNING: At line 36993 of file:/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.xunit-Debug.xml:cvc-complex-type.2.4.d: Invalid content was found starting with element 'properties'. No child element is expected at this point. WARNING: At line 37006 of file:/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/TestResult-Xamarin.Android.Bcl_Tests.xunit-Debug.xml:cvc-complex-type.2.4.d: Invalid content was found starting with element 'properties'. No child element is expected at this point. @akoeplinger also has a patch for the XLST transforms in XUnit. Hopefully this fixes all of our on-device tests!
1 parent 97231f9 commit d8f4335

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Xamarin.Android.NUnitLite/NUnitLite/Runner/OutputWriters/NUnit2XmlOutputWriter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ private void WriteCategories(ITestResult result)
249249

250250
if (properties.ContainsKey(PropertyNames.Category))
251251
{
252+
if (properties[PropertyNames.Category].Count == 0)
253+
return;
254+
252255
xmlWriter.WriteStartElement("categories");
253256

254257
foreach (string category in properties[PropertyNames.Category])

tests/TestRunner.xUnit/NUnitXml.xslt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@
128128
<xsl:value-of select="@time"/>
129129
</xsl:attribute>
130130
</xsl:if>
131+
<xsl:apply-templates select="traits"/>
131132
<xsl:if test="reason">
132133
<reason>
133134
<message>
134135
<xsl:apply-templates select="reason"/>
135136
</message>
136137
</reason>
137138
</xsl:if>
138-
<xsl:apply-templates select="traits"/>
139139
<xsl:apply-templates select="failure"/>
140140
</test-case>
141141
</xsl:template>

0 commit comments

Comments
 (0)