Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: report nested test classes correctly. See #48. #50

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 18 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased (v3.1.x)

- Fix for reporting nested test classes. See #48 and
https://github.com/spekt/testlogger/pull/41/. Thanks @pageyboy.
- Update core testlogger to 3.1.138.
- Infra: fix build when repo is cloned in path with whitespace.

## v3.1.11 - 2023/07/06

- Update core testlogger to 3.1.130.
Expand All @@ -15,25 +20,24 @@
- Fix: Explicit tests should be marked as Skipped. See
https://github.com/spekt/nunit.testlogger/issues/86
- Replace Test Case name parser **Possible Breaking Change**
- For most or maybe all users the new parser should fix the issues shown below, without introducing new issues. In case you do encounter any new parsing failures a feature flag `Parser=Legacy` has been added to use the prior parser. See [logger config wiki](https://github.com/spekt/testlogger/wiki/Logger-Configuration) for details.
- Fix: Test case parse error if name contains special characters. See
https://github.com/spekt/nunit.testlogger/issues/90
- Fix: Covers several parsing issues. Thanks @becha2 for all the detailed examples.
https://github.com/spekt/testlogger/issues/28
- Fix: Log member data. Thanks @BottlecapDave for the issue report and @hach-que for the draft fix.
https://github.com/spekt/junit.testlogger/issues/50
- Fix: Issue parsing chars. Thanks @binarycow for the issue report.
https://github.com/spekt/nunit.testlogger/issues/90
- Reduce log verbosity: The parser, if it encounters problems, will only output one warning per run to the console instead of one per problem
- Fix: Issue parsing numbers. See https://github.com/spekt/testlogger/issues/35

- For most or maybe all users the new parser should fix the issues shown below, without introducing new issues. In case you do encounter any new parsing failures a feature flag `Parser=Legacy` has been added to use the prior parser. See [logger config wiki](https://github.com/spekt/testlogger/wiki/Logger-Configuration) for details.
- Fix: Test case parse error if name contains special characters. See
https://github.com/spekt/nunit.testlogger/issues/90
- Fix: Covers several parsing issues. Thanks @becha2 for all the detailed examples.
https://github.com/spekt/testlogger/issues/28
- Fix: Log member data. Thanks @BottlecapDave for the issue report and @hach-que for the draft fix.
https://github.com/spekt/junit.testlogger/issues/50
- Fix: Issue parsing chars. Thanks @binarycow for the issue report.
https://github.com/spekt/nunit.testlogger/issues/90
- Reduce log verbosity: The parser, if it encounters problems, will only output one warning per run to the console instead of one per problem
- Fix: Issue parsing numbers. See https://github.com/spekt/testlogger/issues/35

## v3.0.70 - 2021/11/01

- Upgrade testlogger to 3.0.47
- Fix: generate test results when used along with JUnit.TestLogger. See
https://github.com/spekt/xunit.testlogger/issues/36 and
https://github.com/spekt/xunit.testlogger/issues/37
https://github.com/spekt/xunit.testlogger/issues/36 and
https://github.com/spekt/xunit.testlogger/issues/37

## v3.0.66 - 2021/03/10

Expand Down
2 changes: 1 addition & 1 deletion scripts/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<MSTestVersion>3.0.4</MSTestVersion>
<NETTestSdkVersion>17.3.2</NETTestSdkVersion>
<MoqVersion>4.18.4</MoqVersion>
<TestLoggerVersion>3.1.130</TestLoggerVersion>
<TestLoggerVersion>3.1.138</TestLoggerVersion>

<!-- Test Assets use the minimum supported versions -->
<NETTestSdkMinimumVersion>15.5.0</NETTestSdkMinimumVersion>
Expand Down
20 changes: 17 additions & 3 deletions test/Xunit.Xml.TestLogger.AcceptanceTests/TestResultsXmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class TestResultsXmlTests : IClassFixture<DotnetTestFixture>
private const string AssembliesElement = @"/assemblies";
private const string AssemblyElement = @"/assemblies/assembly";
private const string CollectionElement = @"/assemblies/assembly/collection";
private const string TotalTestsCount = "9";
private const string TotalPassingTestsCount = "6";
private const int TotalTestClassesCount = 5;

private string testResultsFilePath;
private XmlDocument testResultsXmlDocument;
Expand Down Expand Up @@ -134,15 +137,15 @@ public void AssemblyElementTotalAttributeShouldValueEqualToNumberOfTotalTests()
{
XmlNode assemblyNode = this.testResultsXmlDocument.SelectSingleNode(TestResultsXmlTests.AssemblyElement);

Assert.Equal("6", assemblyNode.Attributes["total"].Value);
Assert.Equal(TotalTestsCount, assemblyNode.Attributes["total"].Value);
}

[Fact]
public void AssemblyElementPassedAttributeShouldValueEqualToNumberOfPassedTests()
{
XmlNode assemblyNode = this.testResultsXmlDocument.SelectSingleNode(TestResultsXmlTests.AssemblyElement);

Assert.Equal("3", assemblyNode.Attributes["passed"].Value);
Assert.Equal(TotalPassingTestsCount, assemblyNode.Attributes["passed"].Value);
}

[Fact]
Expand Down Expand Up @@ -193,7 +196,7 @@ public void CollectionElementsCountShouldBeTwo()
{
XmlNodeList collectionElementNodeList = this.testResultsXmlDocument.SelectNodes(TestResultsXmlTests.CollectionElement);

Assert.Equal(3, collectionElementNodeList.Count);
Assert.Equal(TotalTestClassesCount, collectionElementNodeList.Count);
}

[Fact]
Expand Down Expand Up @@ -351,6 +354,17 @@ public void SkippedTestElementShouldContainSkippingReason()
Assert.Equal(expectedReason, reasonData.Value);
}

[Fact]
public void NestedTestClassesShouldBePresent()
{
XmlNode nestedTestNode = this.GetATestXmlNode(
"ChildUnitNestedTest3332",
"Xunit.Xml.TestLogger.NetCore.Tests.ParentUnitNestedTest3332+ChildUnitNestedTest3332.PassTest33321");
var result = nestedTestNode.Attributes["result"];

Assert.Equal("Pass", result.Value);
}

private XmlNode GetATestXmlNode(
string collectionName = "UnitTest1",
string queryTestName = "Xunit.Xml.TestLogger.NetCore.Tests.UnitTest1.FailTest11")
Expand Down
25 changes: 25 additions & 0 deletions test/assets/Xunit.Xml.TestLogger.NetCore.Tests/NestedTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Xunit;

namespace Xunit.Xml.TestLogger.NetCore.Tests
{
public class ParentUnitNestedTest3331
{
[Fact]
public void PassTest33311()
{
}
}

public class ParentUnitNestedTest3332
{
public class ChildUnitNestedTest3332 : ParentUnitNestedTest3331
{
[Fact]
public void PassTest33321()
{
Assert.Equal(2, 2);
}
}
}
}