From b34d4b1bfe30834973913a18e52217168545ae06 Mon Sep 17 00:00:00 2001 From: Michal Dorner Date: Mon, 28 Jun 2021 22:24:27 +0200 Subject: [PATCH] Add NUnit XML results fixtures --- __tests__/fixtures/dotnet-nunit.xml | 112 ++++++++++++++++ __tests__/fixtures/external/nunit-sample.xml | 125 ++++++++++++++++++ package.json | 1 + .../CalculatorTests.cs | 64 +++++++++ .../DotnetTests.NUnitV3Tests.csproj | 18 +++ reports/dotnet/DotnetTests.sln | 7 + 6 files changed, 327 insertions(+) create mode 100644 __tests__/fixtures/dotnet-nunit.xml create mode 100644 __tests__/fixtures/external/nunit-sample.xml create mode 100644 reports/dotnet/DotnetTests.NUnitV3Tests/CalculatorTests.cs create mode 100644 reports/dotnet/DotnetTests.NUnitV3Tests/DotnetTests.NUnitV3Tests.csproj diff --git a/__tests__/fixtures/dotnet-nunit.xml b/__tests__/fixtures/dotnet-nunit.xml new file mode 100644 index 0000000..e08a9f3 --- /dev/null +++ b/__tests__/fixtures/dotnet-nunit.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/__tests__/fixtures/external/nunit-sample.xml b/__tests__/fixtures/external/nunit-sample.xml new file mode 100644 index 0000000..b261560 --- /dev/null +++ b/__tests__/fixtures/external/nunit-sample.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 3f15642..a52075a 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "all": "npm run build && npm run format && npm run lint && npm run package && npm test", "dart-fixture": "cd \"reports/dart\" && dart test --file-reporter=\"json:../../__tests__/fixtures/dart-json.json\"", "dotnet-fixture": "dotnet test reports/dotnet/DotnetTests.XUnitTests --logger \"trx;LogFileName=../../../../__tests__/fixtures/dotnet-trx.trx\"", + "dotnet-nunit-fixture": "nunit.exe reports/dotnet/DotnetTests.NUnitV3Tests/bin/Debug/netcoreapp3.1/DotnetTests.NUnitV3Tests.dll --result=__tests__/fixtures/dotnet-nunit.xml", "jest-fixture": "cd \"reports/jest\" && npm test", "mocha-fixture": "cd \"reports/mocha\" && npm test" }, diff --git a/reports/dotnet/DotnetTests.NUnitV3Tests/CalculatorTests.cs b/reports/dotnet/DotnetTests.NUnitV3Tests/CalculatorTests.cs new file mode 100644 index 0000000..9452ae9 --- /dev/null +++ b/reports/dotnet/DotnetTests.NUnitV3Tests/CalculatorTests.cs @@ -0,0 +1,64 @@ +using System; +using System.Threading; +using DotnetTests.Unit; +using NUnit.Framework; + +namespace DotnetTests.XUnitTests +{ + public class CalculatorTests + { + private readonly Calculator _calculator = new Calculator(); + + [Test] + public void Passing_Test() + { + Assert.That(_calculator.Sum(1, 1), Is.EqualTo(2)); + } + + [Test(Description = "Some description")] + public void Passing_Test_With_Description() + { + Assert.That(2, Is.EqualTo(2)); + } + + [Test] + public void Failing_Test() + { + Assert.That(_calculator.Sum(1, 1), Is.EqualTo(3)); + } + + [Test] + public void Exception_In_TargetTest() + { + _calculator.Div(1, 0); + } + + [Test] + public void Exception_In_Test() + { + throw new Exception("Test"); + } + + [Test] + [Timeout(1)] + public void Timeout_Test() + { + Thread.Sleep(100); + } + + [Test] + [Ignore("Skipped")] + public void Skipped_Test() + { + throw new Exception("Test"); + } + + [Theory] + [TestCase(2)] + [TestCase(3)] + public void Is_Even_Number(int i) + { + Assert.True(i % 2 == 0); + } + } +} diff --git a/reports/dotnet/DotnetTests.NUnitV3Tests/DotnetTests.NUnitV3Tests.csproj b/reports/dotnet/DotnetTests.NUnitV3Tests/DotnetTests.NUnitV3Tests.csproj new file mode 100644 index 0000000..932ff5b --- /dev/null +++ b/reports/dotnet/DotnetTests.NUnitV3Tests/DotnetTests.NUnitV3Tests.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + diff --git a/reports/dotnet/DotnetTests.sln b/reports/dotnet/DotnetTests.sln index 1c0bbeb..7c5ff87 100644 --- a/reports/dotnet/DotnetTests.sln +++ b/reports/dotnet/DotnetTests.sln @@ -9,6 +9,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BCAC3B31 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotnetTests.XUnitTests", "DotnetTests.XUnitTests\DotnetTests.XUnitTests.csproj", "{F8607EDB-D25D-47AA-8132-38ACA242E845}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotnetTests.NUnitV3Tests", "DotnetTests.NUnitV3Tests\DotnetTests.NUnitV3Tests.csproj", "{81023ED7-56CB-47E9-86C5-9125A0873C55}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,12 +25,17 @@ Global {F8607EDB-D25D-47AA-8132-38ACA242E845}.Debug|Any CPU.Build.0 = Debug|Any CPU {F8607EDB-D25D-47AA-8132-38ACA242E845}.Release|Any CPU.ActiveCfg = Release|Any CPU {F8607EDB-D25D-47AA-8132-38ACA242E845}.Release|Any CPU.Build.0 = Release|Any CPU + {81023ED7-56CB-47E9-86C5-9125A0873C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81023ED7-56CB-47E9-86C5-9125A0873C55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81023ED7-56CB-47E9-86C5-9125A0873C55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81023ED7-56CB-47E9-86C5-9125A0873C55}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {F8607EDB-D25D-47AA-8132-38ACA242E845} = {BCAC3B31-ADB1-4221-9D5B-182EE868648C} + {81023ED7-56CB-47E9-86C5-9125A0873C55} = {BCAC3B31-ADB1-4221-9D5B-182EE868648C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6ED5543C-74AA-4B21-8050-943550F3F66E}