From 96ad96d584d5d800e000b3bc1d9e981960fef3a5 Mon Sep 17 00:00:00 2001 From: Shamus Taylor Date: Wed, 5 Mar 2025 09:46:34 -0600 Subject: [PATCH] Add nunit-legacy fixture generation code --- __tests__/fixtures/dotnet-nunit-legacy2.xml | 82 +++++++++++++++++++ package.json | 1 + reports/dotnet-nunit-legacy/.gitignore | 4 + .../MyLibrary/Calculator.cs | 9 ++ .../MyLibrary/MyLibrary.csproj | 48 +++++++++++ .../MyLibrary/Properties/AssemblyInfo.cs | 36 ++++++++ reports/dotnet-nunit-legacy/NUnitLegacy.sln | 31 +++++++ .../NUnitLegacyTests/CalculatorTests.cs | 71 ++++++++++++++++ .../NUnitLegacyTests/NUnitLegacyTests.csproj | 71 ++++++++++++++++ .../Properties/AssemblyInfo.cs | 20 +++++ .../NUnitLegacyTests/packages.config | 6 ++ 11 files changed, 379 insertions(+) create mode 100644 __tests__/fixtures/dotnet-nunit-legacy2.xml create mode 100644 reports/dotnet-nunit-legacy/.gitignore create mode 100644 reports/dotnet-nunit-legacy/MyLibrary/Calculator.cs create mode 100644 reports/dotnet-nunit-legacy/MyLibrary/MyLibrary.csproj create mode 100644 reports/dotnet-nunit-legacy/MyLibrary/Properties/AssemblyInfo.cs create mode 100644 reports/dotnet-nunit-legacy/NUnitLegacy.sln create mode 100644 reports/dotnet-nunit-legacy/NUnitLegacyTests/CalculatorTests.cs create mode 100644 reports/dotnet-nunit-legacy/NUnitLegacyTests/NUnitLegacyTests.csproj create mode 100644 reports/dotnet-nunit-legacy/NUnitLegacyTests/Properties/AssemblyInfo.cs create mode 100644 reports/dotnet-nunit-legacy/NUnitLegacyTests/packages.config diff --git a/__tests__/fixtures/dotnet-nunit-legacy2.xml b/__tests__/fixtures/dotnet-nunit-legacy2.xml new file mode 100644 index 0000000..45104e3 --- /dev/null +++ b/__tests__/fixtures/dotnet-nunit-legacy2.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 69f2515..e3262bd 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "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", + "dotnet-nunit-legacy-fixture": "nunit-console.exe reports/dotnet-nunit-legacy/NUnitLegacy.sln --result=__tests__/fixtures/dotnet-nunit-legacy2.xml", "jest-fixture": "cd \"reports/jest\" && npm test", "mocha-fixture": "cd \"reports/mocha\" && npm test" }, diff --git a/reports/dotnet-nunit-legacy/.gitignore b/reports/dotnet-nunit-legacy/.gitignore new file mode 100644 index 0000000..5d8c6bd --- /dev/null +++ b/reports/dotnet-nunit-legacy/.gitignore @@ -0,0 +1,4 @@ +packages/ +bin/ +obj/ +.vs/ diff --git a/reports/dotnet-nunit-legacy/MyLibrary/Calculator.cs b/reports/dotnet-nunit-legacy/MyLibrary/Calculator.cs new file mode 100644 index 0000000..c7fb078 --- /dev/null +++ b/reports/dotnet-nunit-legacy/MyLibrary/Calculator.cs @@ -0,0 +1,9 @@ +namespace MyLibrary +{ + public class Calculator + { + public int Sum(int a, int b) => a + b; + + public int Div(int a, int b) => a / b; + } +} diff --git a/reports/dotnet-nunit-legacy/MyLibrary/MyLibrary.csproj b/reports/dotnet-nunit-legacy/MyLibrary/MyLibrary.csproj new file mode 100644 index 0000000..2bc5013 --- /dev/null +++ b/reports/dotnet-nunit-legacy/MyLibrary/MyLibrary.csproj @@ -0,0 +1,48 @@ + + + + + Debug + AnyCPU + {157F3352-FB50-4C32-A555-8FF98888CCB6} + Library + Properties + MyLibrary + MyLibrary + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reports/dotnet-nunit-legacy/MyLibrary/Properties/AssemblyInfo.cs b/reports/dotnet-nunit-legacy/MyLibrary/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eba9543 --- /dev/null +++ b/reports/dotnet-nunit-legacy/MyLibrary/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MyLibrary")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MyLibrary")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("157f3352-fb50-4c32-a555-8ff98888ccb6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/reports/dotnet-nunit-legacy/NUnitLegacy.sln b/reports/dotnet-nunit-legacy/NUnitLegacy.sln new file mode 100644 index 0000000..b02321a --- /dev/null +++ b/reports/dotnet-nunit-legacy/NUnitLegacy.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1927 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnitLegacyTests", "NUnitLegacyTests\NUnitLegacyTests.csproj", "{28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyLibrary", "MyLibrary\MyLibrary.csproj", "{157F3352-FB50-4C32-A555-8FF98888CCB6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B}.Release|Any CPU.Build.0 = Release|Any CPU + {157F3352-FB50-4C32-A555-8FF98888CCB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {157F3352-FB50-4C32-A555-8FF98888CCB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {157F3352-FB50-4C32-A555-8FF98888CCB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {157F3352-FB50-4C32-A555-8FF98888CCB6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D64049EC-5C5F-4FBE-AC6C-2DBB54DD3D6F} + EndGlobalSection +EndGlobal diff --git a/reports/dotnet-nunit-legacy/NUnitLegacyTests/CalculatorTests.cs b/reports/dotnet-nunit-legacy/NUnitLegacyTests/CalculatorTests.cs new file mode 100644 index 0000000..b782858 --- /dev/null +++ b/reports/dotnet-nunit-legacy/NUnitLegacyTests/CalculatorTests.cs @@ -0,0 +1,71 @@ +using MyLibrary; +using NUnit.Framework; +using System; +using System.Threading; + +namespace NUnitLegacyTests +{ + 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); + } + + [Test] + public void Inconclusive_Test() + { + Assert.Inconclusive("couldn't run test for some reason"); + } + } + +} diff --git a/reports/dotnet-nunit-legacy/NUnitLegacyTests/NUnitLegacyTests.csproj b/reports/dotnet-nunit-legacy/NUnitLegacyTests/NUnitLegacyTests.csproj new file mode 100644 index 0000000..49c0090 --- /dev/null +++ b/reports/dotnet-nunit-legacy/NUnitLegacyTests/NUnitLegacyTests.csproj @@ -0,0 +1,71 @@ + + + + + + Debug + AnyCPU + {28C713F2-6E53-41A0-9B2C-6AC6FF1DB80B} + Library + Properties + NUnitLegacyTests + NUnitLegacyTests + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NUnit.2.7.1\lib\nunit.framework.dll + + + + + + + + + + + + + + {157F3352-FB50-4C32-A555-8FF98888CCB6} + MyLibrary + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/reports/dotnet-nunit-legacy/NUnitLegacyTests/Properties/AssemblyInfo.cs b/reports/dotnet-nunit-legacy/NUnitLegacyTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..eeb131b --- /dev/null +++ b/reports/dotnet-nunit-legacy/NUnitLegacyTests/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("NUnitLegacyTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NUnitLegacyTests")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("28c713f2-6e53-41a0-9b2c-6ac6ff1db80b")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/reports/dotnet-nunit-legacy/NUnitLegacyTests/packages.config b/reports/dotnet-nunit-legacy/NUnitLegacyTests/packages.config new file mode 100644 index 0000000..8081550 --- /dev/null +++ b/reports/dotnet-nunit-legacy/NUnitLegacyTests/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file