Skip to content

Commit

Permalink
Fix XUnit 2.5.0 breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Aug 2, 2023
1 parent b1025c9 commit 679e1c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion TestAssetsXunit/TestAssetsXunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />

<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit" Version="2.5.0" />

<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
25 changes: 14 additions & 11 deletions TestDotnetTestSplit/TestAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@

namespace Test4Giis.DotnetTestSplit
{
/// <summary>
/// Tests are intended to run from commandline, in a GitHub Acctions workflow or in local:
/// Execute commands in file run-test.bat that
/// - Generates the test assets for each platform by executing the tess (most of tests must fail)
/// - Optionally execute 'ant report' to see a junit style html report for each platform
/// - Compiles, installs and executes DotnetTestSplit
/// - Executes this test or each class and platform producing the result in a .trx file
/// under the TestResults folder of this project
/// - As comparison is made with VisualAssert, the html files that were produced containt the detailed
/// expected/actual test comparison
/// </summary>
[TestFixture]
public class TestSplit
{
Expand All @@ -30,24 +41,16 @@ public class TestSplit
[TestCase("Xunit", "Stp.ClassStp")]
public void TestAll(string framework, string testClass)
{
//Generation of trx files y split must be executed from outside
// Generation of trx files y split must be executed from outside
// Here we compare th splitted files for all combinations of class that produce the report and platform
// Uses VisualAssert to have a clear display of differences in tests that fail
string testFileName = "TEST-TestAssets" + framework + "." + testClass + ".xml";
string expectedFolder = "../../../../expected/" + framework.ToLower() + "-report.trx.split";
string outFolder = "../../../../reports/" + framework.ToLower() + "-report.trx.split";
//uncomment/customize only for debug
//DotnetTestSplitMain w = new DotnetTestSplitMain();
//w.Run("../../../../reports/mstest-report.trx", outFolder);

//remove times and sort expected and actual to make comparable
string expected = ReadComparable(Path.Combine(expectedFolder, testFileName));
string actual = ReadComparable(Path.Combine(outFolder, testFileName));

//to manually check differences of compared data
//Directory.CreateDirectory(Path.Combine(outFolder + "compare-expected"));
//Directory.CreateDirectory(Path.Combine(outFolder + "compare-actual"));
//File.WriteAllText(Path.Combine(outFolder + "compare-expected", testFileName), expected);
//File.WriteAllText(Path.Combine(outFolder + "compare-actual", testFileName), actual);

VisualAssert va = new VisualAssert().SetUseLocalAbsolutePath(true);
va.AssertEquals(expected, actual, "Comparing file: " + testFileName, testFileName + ".html");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<testsuite name="TestAssetsXunit.One.ClassTwo" tests="6" failures="3" errors="0" skipped="2" time="0.0068434" >
<testcase classname="TestAssetsXunit.One.ClassTwo" name="TestAssetsXunit.One.ClassTwo.TestOneTwoFail" outcome="Failed" time="0.0005096"><failure>
MESSAGE:
Assert.Equal() Failure
Assert.Equal() Failure: Values differ
Expected: 1
Actual: 2
+++++++++++++++++++
Expand All @@ -11,8 +11,6 @@ STACK TRACE:
<testcase classname="TestAssetsXunit.One.ClassTwo" name="TestAssetsXunit.One.ClassTwo.TestOneTwoFailMessage" outcome="Failed" time="0.0007686"><failure>
MESSAGE:
This is a failure message
Expected: True
Actual: False
+++++++++++++++++++
STACK TRACE:
at TestAssetsXunit.One.ClassTwo.TestOneTwoFailMessage() in /TestAssetsXunit/TestAssetsXunit.cs:line 46</failure></testcase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<testcase classname="TestAssetsXunit.Two.ClassTwo" name="TestAssetsXunit.Two.ClassTwo.TestTwoTwoParametrized(expected: 2, actual: 1)" outcome="Passed" time="0.0055664" />
<testcase classname="TestAssetsXunit.Two.ClassTwo" name="TestAssetsXunit.Two.ClassTwo.TestTwoTwoParametrized(expected: 88, actual: 4)" outcome="Failed" time="0.0036297"><failure>
MESSAGE:
Assert.Equal() Failure
Assert.Equal() Failure: Values differ
Expected: 88
Actual: 8
+++++++++++++++++++
Expand Down

0 comments on commit 679e1c7

Please sign in to comment.