From ef16c3ae6e25d787f284f71218bb2bf8d4f7c720 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Sat, 23 Mar 2024 03:16:28 +0700 Subject: [PATCH 01/13] Use common failed/broken algorithm by allure-xunit --- Allure.XUnit/AllureMessageSink.cs | 6 ++++++ Allure.XUnit/AllureXunitHelper.cs | 18 ++++++------------ .../Attributes/Steps/AllureAfterAttribute.cs | 2 +- .../Attributes/Steps/AllureBeforeAttribute.cs | 3 +-- .../Attributes/Steps/AllureStepAttribute.cs | 3 +-- Allure.XUnit/TypeExtensions.cs | 2 -- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.XUnit/AllureMessageSink.cs index f84050ab..d8d5cc93 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.XUnit/AllureMessageSink.cs @@ -7,6 +7,7 @@ using Allure.Xunit; using Xunit; using Xunit.Abstractions; +using Xunit.Sdk; #nullable enable @@ -49,6 +50,11 @@ MessageHandlerArgs args ) { args.Message.ExecutionOptions.SetSynchronousMessageReporting(true); + AllureLifecycle.Instance.AllureConfiguration.FailExceptions ??= new() + { + typeof(XunitException).FullName, // v2.4.1 and earlier + "Xunit.Sdk.IAssertionException" // v2.4.2 and onward + }; } internal bool SelectByTestPlan(ITest test) diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 5bf99b3f..68ae9736 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -1,16 +1,15 @@ -using Allure.Net.Commons; -using Allure.Net.Commons.Functions; -using Allure.Xunit.Attributes; -using Allure.XUnit; -using Allure.XUnit.Attributes; using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; +using Allure.Net.Commons; +using Allure.Net.Commons.Functions; +using Allure.Xunit.Attributes; +using Allure.XUnit; +using Allure.XUnit.Attributes; using Xunit; using Xunit.Abstractions; -using Xunit.Sdk; #nullable enable @@ -24,11 +23,6 @@ internal interface ITestResultAccessor TestResult TestResult { get; set; } } - internal static List ExceptionTypes = new() - { - typeof(XunitException) - }; - static AllureXunitHelper() { const string allureConfigEnvVariable = "ALLURE_CONFIG"; @@ -204,7 +198,7 @@ bool overwrite { labels.RemoveAll(label => label.name == labelToInsert.name); } - + labels.Add(labelToInsert); } diff --git a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs index 241e9193..3e9d03d1 100644 --- a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs @@ -5,7 +5,7 @@ namespace Allure.XUnit.Attributes.Steps { public class AllureAfterAttribute : AllureStepAttributes.AbstractAfterAttribute { - public AllureAfterAttribute(string name = null) : base(name, AllureXunitHelper.ExceptionTypes) + public AllureAfterAttribute(string name = null) : base(name) { } } diff --git a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs index 9602f1ff..4591b331 100644 --- a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs @@ -1,11 +1,10 @@ using Allure.Net.Commons.Steps; -using Allure.Xunit; namespace Allure.XUnit.Attributes.Steps { public class AllureBeforeAttribute : AllureStepAttributes.AbstractBeforeAttribute { - public AllureBeforeAttribute(string name = null) : base(name, AllureXunitHelper.ExceptionTypes) + public AllureBeforeAttribute(string name = null) : base(name) { } } diff --git a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs index 0dccb610..b5a6a333 100644 --- a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs @@ -1,11 +1,10 @@ using Allure.Net.Commons.Steps; -using Allure.Xunit; namespace Allure.XUnit.Attributes.Steps { public class AllureStepAttribute : AllureStepAttributes.AbstractStepAttribute { - public AllureStepAttribute(string name = null) : base(name, AllureXunitHelper.ExceptionTypes) + public AllureStepAttribute(string name = null) : base(name) { } } diff --git a/Allure.XUnit/TypeExtensions.cs b/Allure.XUnit/TypeExtensions.cs index f978ca21..4951c325 100644 --- a/Allure.XUnit/TypeExtensions.cs +++ b/Allure.XUnit/TypeExtensions.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Reflection; using System.Text; -using Allure.Net.Commons.Steps; -using Xunit.Sdk; namespace Allure.XUnit { From 3c59709d932a4757683e2af46dee55e4e9ef1d3a Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Sat, 23 Mar 2024 03:30:34 +0700 Subject: [PATCH 02/13] Remove obsolete allure-xunit's example --- Allure.XUnit.Examples/ExampleSteps.cs | 69 --------------------------- 1 file changed, 69 deletions(-) delete mode 100644 Allure.XUnit.Examples/ExampleSteps.cs diff --git a/Allure.XUnit.Examples/ExampleSteps.cs b/Allure.XUnit.Examples/ExampleSteps.cs deleted file mode 100644 index 2fdf9b7a..00000000 --- a/Allure.XUnit.Examples/ExampleSteps.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Threading.Tasks; -using Allure.Xunit; -using Allure.Xunit.Attributes; -using Xunit; -using Xunit.Abstractions; - -namespace Allure.XUnit.Examples; - -[Obsolete("See ExampleStepAttributes")] -[AllureSuite("ExampleSteps (Obsolete)")] -public class ExampleSteps : IAsyncLifetime -{ - ITestOutputHelper output; - - public ExampleSteps(ITestOutputHelper output) - { - this.output = output; - } - - public Task InitializeAsync() - { - using (new AllureBefore("Initialization")) - { - using (new AllureStep("Nested")) - { - return Task.CompletedTask; - } - } - } - - public Task DisposeAsync() - { - using var _ = new AllureAfter("Cleanup"); - return Task.CompletedTask; - } - - [Fact(Skip = "ExampleSteps is obsolete")] - public async Task TestParameters() - { - WriteHello(42, 4242, "secret"); - await AddAttachment(); - } - - [Fact(Skip = "ExampleSteps is obsolete")] - public void TestFail() - { - using (new AllureStep("Test Fail")) - { - using (new AllureStep("Nested")) - { - throw new Exception(); - } - } - } - - private void WriteHello(int parameter, int renameMe, string password) - { - using (new AllureStep("Write Hello").SetParameter(parameter).SetParameter("value", renameMe)) - { - this.output.WriteLine("Hello from Step"); - } - } - - private static async Task AddAttachment() - { - await AllureAttachments.Text("large json", "{}"); - } -} \ No newline at end of file From 94815713757b269cc83b7c9bd3b07de18942df62 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Sat, 23 Mar 2024 05:21:45 +0700 Subject: [PATCH 03/13] Remove false warning for skipped theories (#421) --- Allure.XUnit/AllureMessageSink.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.XUnit/AllureMessageSink.cs index d8d5cc93..a86a1ac6 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.XUnit/AllureMessageSink.cs @@ -184,7 +184,10 @@ void AddAllureParameters(ITest test, object[]? arguments) if (parameters.Any() && !arguments.Any()) { - this.LogUnreportedTheoryArgs(test.DisplayName); + if (string.IsNullOrEmpty(test.TestCase.SkipReason)) + { + this.LogUnreportedTheoryArgs(test.DisplayName); + } } else { @@ -213,8 +216,8 @@ void LogUnreportedTheoryArgs(string testName) var message = $"Unable to attach arguments of {testName} to " + "allure report"; #if !DEBUG - message += ". You may try to compile the project in debug mode " + - "as a workaround"; + message += ". Try to compile the project in debug mode as a " + + "workaround"; #endif this.Logger.LogWarning(message); } From f0c314b63dab4400b3364ff18cf4a3bbfb7d01d3 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:39:12 +0700 Subject: [PATCH 04/13] Use the common skip reason for test plans --- Allure.XUnit/AllureXunitPatcher.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Allure.XUnit/AllureXunitPatcher.cs b/Allure.XUnit/AllureXunitPatcher.cs index 88aaae54..5c070861 100644 --- a/Allure.XUnit/AllureXunitPatcher.cs +++ b/Allure.XUnit/AllureXunitPatcher.cs @@ -1,5 +1,6 @@ -using HarmonyLib; using System; +using Allure.Net.Commons.TestPlan; +using HarmonyLib; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; @@ -98,10 +99,10 @@ private static void OnTestRunnerCreating(ITest test, ref string skipReason) { if (!CurrentSink.SelectByTestPlan(test)) { - skipReason = "Deselected by the test plan."; + skipReason = AllureTestPlan.SkipReason; } } - private static void OnTestRunnerCreated(ITest test, object[] testMethodArguments) => + private static void OnTestRunnerCreated(ITest test, object[] testMethodArguments) => CurrentSink.OnTestArgumentsCreated(test, testMethodArguments); } \ No newline at end of file From bb69cb4cf2905787849d87b02b9730c8ec369124 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:56:27 +0700 Subject: [PATCH 05/13] Remove separate project for xunit reporter --- Allure.XUnit.Examples/Allure.XUnit.Examples.csproj | 1 - .../Allure.XUnit.Reporters.csproj | 14 -------------- Allure.XUnit/Allure.XUnit.csproj | 8 +------- .../AllureRunnerReporter.cs | 2 +- allure-csharp.sln | 9 --------- 5 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 Allure.XUnit.Reporters/Allure.XUnit.Reporters.csproj rename {Allure.XUnit.Reporters => Allure.XUnit}/AllureRunnerReporter.cs (93%) diff --git a/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj b/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj index e26b6f4a..7ffcf3df 100644 --- a/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj +++ b/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj @@ -20,7 +20,6 @@ - diff --git a/Allure.XUnit.Reporters/Allure.XUnit.Reporters.csproj b/Allure.XUnit.Reporters/Allure.XUnit.Reporters.csproj deleted file mode 100644 index 65851e41..00000000 --- a/Allure.XUnit.Reporters/Allure.XUnit.Reporters.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Allure.XUnit.reporters - netcoreapp2.0;netstandard2.1;net5.0;net6.0 - enable - - - - - - - - diff --git a/Allure.XUnit/Allure.XUnit.csproj b/Allure.XUnit/Allure.XUnit.csproj index e9318cd4..c9c27e28 100644 --- a/Allure.XUnit/Allure.XUnit.csproj +++ b/Allure.XUnit/Allure.XUnit.csproj @@ -1,6 +1,7 @@  + Allure.XUnit.reporters netcoreapp2.0;netstandard2.1;net5.0;net6.0 true Allure.XUnit @@ -31,11 +32,4 @@ - - - - - - - diff --git a/Allure.XUnit.Reporters/AllureRunnerReporter.cs b/Allure.XUnit/AllureRunnerReporter.cs similarity index 93% rename from Allure.XUnit.Reporters/AllureRunnerReporter.cs rename to Allure.XUnit/AllureRunnerReporter.cs index 4c2a12d8..894bd0de 100644 --- a/Allure.XUnit.Reporters/AllureRunnerReporter.cs +++ b/Allure.XUnit/AllureRunnerReporter.cs @@ -3,7 +3,7 @@ #nullable enable -namespace Allure.XUnit.Reporters +namespace Allure.XUnit { public class AllureRunnerReporter : IRunnerReporter { diff --git a/allure-csharp.sln b/allure-csharp.sln index ea49eae3..0d6944f1 100644 --- a/allure-csharp.sln +++ b/allure-csharp.sln @@ -29,8 +29,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.NUnit", "Allure.NUni EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.NUnit.Examples", "Allure.NUnit.Examples\Allure.NUnit.Examples.csproj", "{77893A8D-4313-4211-AFF1-642E866A07C7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.XUnit.Reporters", "Allure.XUnit.Reporters\Allure.XUnit.Reporters.csproj", "{5A5F20A0-9728-4554-8CD7-850698A0061F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{28DC4686-88DF-416F-A170-F3917C013136}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore @@ -116,12 +114,6 @@ Global {77893A8D-4313-4211-AFF1-642E866A07C7}.Publish|Any CPU.ActiveCfg = Debug|Any CPU {77893A8D-4313-4211-AFF1-642E866A07C7}.Release|Any CPU.ActiveCfg = Release|Any CPU {77893A8D-4313-4211-AFF1-642E866A07C7}.Release|Any CPU.Build.0 = Release|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Publish|Any CPU.ActiveCfg = Release|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Publish|Any CPU.Build.0 = Release|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5A5F20A0-9728-4554-8CD7-850698A0061F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -136,7 +128,6 @@ Global {38CF463E-F564-477D-A853-407F0648E0DD} = {138A76FC-B163-423C-8FF8-D374F1C7EC2F} {81F804C5-C437-4079-9731-97C6A2A86C48} = {D0D75FDF-4884-4AC1-868F-B3F248CB74ED} {77893A8D-4313-4211-AFF1-642E866A07C7} = {D0D75FDF-4884-4AC1-868F-B3F248CB74ED} - {5A5F20A0-9728-4554-8CD7-850698A0061F} = {138A76FC-B163-423C-8FF8-D374F1C7EC2F} {8A134D07-3424-4238-BD71-C5B7D35F6C36} = {FD04A838-5AD5-417C-AD5B-1E5C4164AF62} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution From 557b5771338b18d8452f482af0ad2029b903a3db Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:54:43 +0700 Subject: [PATCH 06/13] Consolidate Allure.Xunit under single namespace --- .github/labeler.yml | 4 ++-- .github/workflows/release.yml | 8 +++---- .../ExampleParameterisedTests.cs | 4 ++-- .../ExampleStepAttributes.cs | 4 ++-- Allure.XUnit.Examples/ExampleUnitTests.cs | 2 +- Allure.XUnit.Examples/TestData/MyTestClass.cs | 2 +- .../TestData/TestClassData.cs | 2 +- .../TestData/TestDataGenerators.cs | 2 +- Allure.XUnit/Allure.XUnit.csproj | 3 +-- Allure.XUnit/AllureAttachments.cs | 2 +- Allure.XUnit/AllureMessageSink.cs | 3 +-- Allure.XUnit/AllureRunnerReporter.cs | 2 +- Allure.XUnit/AllureXunitConfiguration.cs | 2 +- Allure.XUnit/AllureXunitFacade.cs | 2 +- Allure.XUnit/AllureXunitHelper.cs | 5 ++-- Allure.XUnit/AllureXunitPatcher.cs | 4 ++-- Allure.XUnit/AllureXunitTestData.cs | 2 +- Allure.XUnit/Attachments.cs | 24 +++++++++++++++++-- .../Attributes/AllureDescriptionAttribute.cs | 1 - .../Attributes/AllureEpicAttribute.cs | 1 - .../Attributes/AllureFeatureAttribute.cs | 1 - Allure.XUnit/Attributes/AllureIdAttribute.cs | 1 - .../Attributes/AllureIssueAttribute.cs | 1 - .../Attributes/AllureLabelAttribute.cs | 1 - .../Attributes/AllureLinkAttribute.cs | 1 - .../Attributes/AllureOwnerAttribute.cs | 1 - .../Attributes/AllureParentSuiteAttribute.cs | 1 - .../Attributes/AllureSeverityAttribute.cs | 1 - .../Attributes/AllureStoryAttribute.cs | 1 - .../Attributes/AllureSubSuiteAttribute.cs | 1 - .../Attributes/AllureSuiteAttribute.cs | 1 - Allure.XUnit/Attributes/AllureTagAttribute.cs | 1 - Allure.XUnit/Attributes/IAllureInfo.cs | 2 +- .../Attributes/Steps/AllureAfterAttribute.cs | 14 +++++++++++ .../Attributes/Steps/AllureBeforeAttribute.cs | 15 ++++++++++++ .../Attributes/Steps/AllureStepAttribute.cs | 15 ++++++++++++ .../Attributes/Steps/NameAttribute.cs | 15 ++++++++++++ .../Attributes/Steps/SkipAttribute.cs | 12 ++++++++++ Allure.XUnit/ComposedMessageSink.cs | 2 +- Allure.XUnit/README.md | 22 ++++++++--------- Allure.XUnit/TypeExtensions.cs | 2 +- README.md | 2 +- allure-csharp.sln | 4 ++-- 43 files changed, 136 insertions(+), 60 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 8a747abd..57313b26 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -19,8 +19,8 @@ "theme:xunit": - changed-files: - any-glob-to-any-file: - - "Allure.XUnit/**" - - "Allure.XUnit.Tests/**" + - "Allure.Xunit/**" + - "Allure.Xunit.Examples/**" "theme:nunit": - changed-files: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11287dc0..4ce46efb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,16 +51,16 @@ jobs: run: | sed -i -e '/"$ref"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.NUnit/Schemas/allureConfig.schema.json cat ./Allure.NUnit/Schemas/allureConfig.schema.json - sed -i -e '/"$ref"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.XUnit/Schemas/allureConfig.schema.json - cat ./Allure.XUnit/Schemas/allureConfig.schema.json + sed -i -e '/"$ref"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.Xunit/Schemas/allureConfig.schema.json + cat ./Allure.Xunit/Schemas/allureConfig.schema.json sed -i -e '/"$ref"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.SpecFlowPlugin/Schemas/allureConfig.schema.json cat ./Allure.SpecFlowPlugin/Schemas/allureConfig.schema.json sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.Net.Commons/allureConfig.Template.json cat ./Allure.Net.Commons/allureConfig.Template.json sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.NUnit.Examples/allureConfig.json cat ./Allure.NUnit.Examples/allureConfig.json - sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.XUnit.Examples/allureConfig.json - cat ./Allure.XUnit.Examples/allureConfig.json + sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.Xunit.Examples/allureConfig.json + cat ./Allure.Xunit.Examples/allureConfig.json sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.SpecFlowPlugin/allureConfig.Template.json cat ./Allure.SpecFlowPlugin/allureConfig.Template.json sed -i -e '/"$schema"/s|/allure-csharp/[^/]*|/allure-csharp/${{ env.release_version }}|g' ./Allure.Features/allureConfig.json diff --git a/Allure.XUnit.Examples/ExampleParameterisedTests.cs b/Allure.XUnit.Examples/ExampleParameterisedTests.cs index 520bc158..18121bf0 100644 --- a/Allure.XUnit.Examples/ExampleParameterisedTests.cs +++ b/Allure.XUnit.Examples/ExampleParameterisedTests.cs @@ -2,10 +2,10 @@ using System.Diagnostics; using System.IO; using Allure.Xunit.Attributes; -using Allure.XUnit.Examples.TestData; +using Allure.Xunit.Examples.TestData; using Xunit; -namespace Allure.XUnit.Examples +namespace Allure.Xunit.Examples { public class ExampleParameterisedTests { diff --git a/Allure.XUnit.Examples/ExampleStepAttributes.cs b/Allure.XUnit.Examples/ExampleStepAttributes.cs index 2f7c35f9..b4974ad8 100644 --- a/Allure.XUnit.Examples/ExampleStepAttributes.cs +++ b/Allure.XUnit.Examples/ExampleStepAttributes.cs @@ -1,9 +1,9 @@ using System; using Allure.Xunit.Attributes; -using Allure.XUnit.Attributes.Steps; +using Allure.Xunit.Attributes.Steps; using Xunit; -namespace Allure.XUnit.Examples; +namespace Allure.Xunit.Examples; [AllureSuite("StepAttributes")] public class ExampleStepAttributes : IDisposable diff --git a/Allure.XUnit.Examples/ExampleUnitTests.cs b/Allure.XUnit.Examples/ExampleUnitTests.cs index e67a8cfb..6ed90334 100644 --- a/Allure.XUnit.Examples/ExampleUnitTests.cs +++ b/Allure.XUnit.Examples/ExampleUnitTests.cs @@ -6,7 +6,7 @@ using Allure.Xunit.Attributes; using Xunit; -namespace Allure.XUnit.Examples +namespace Allure.Xunit.Examples { [AllureOwner("Tinkoff")] [AllureTag("TAG-ALL")] diff --git a/Allure.XUnit.Examples/TestData/MyTestClass.cs b/Allure.XUnit.Examples/TestData/MyTestClass.cs index bac23d88..99f1dcf1 100644 --- a/Allure.XUnit.Examples/TestData/MyTestClass.cs +++ b/Allure.XUnit.Examples/TestData/MyTestClass.cs @@ -1,4 +1,4 @@ -namespace Allure.XUnit.Examples +namespace Allure.Xunit.Examples.TestData { public class MyTestClass { diff --git a/Allure.XUnit.Examples/TestData/TestClassData.cs b/Allure.XUnit.Examples/TestData/TestClassData.cs index ccb29e24..b3a9be8a 100644 --- a/Allure.XUnit.Examples/TestData/TestClassData.cs +++ b/Allure.XUnit.Examples/TestData/TestClassData.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace Allure.XUnit.Examples +namespace Allure.Xunit.Examples.TestData { public class TestClassData : IEnumerable { diff --git a/Allure.XUnit.Examples/TestData/TestDataGenerators.cs b/Allure.XUnit.Examples/TestData/TestDataGenerators.cs index 7ce47ff9..150a153c 100644 --- a/Allure.XUnit.Examples/TestData/TestDataGenerators.cs +++ b/Allure.XUnit.Examples/TestData/TestDataGenerators.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace Allure.XUnit.Examples.TestData +namespace Allure.Xunit.Examples.TestData { public class TestDataGenerators { diff --git a/Allure.XUnit/Allure.XUnit.csproj b/Allure.XUnit/Allure.XUnit.csproj index c9c27e28..c3dd6797 100644 --- a/Allure.XUnit/Allure.XUnit.csproj +++ b/Allure.XUnit/Allure.XUnit.csproj @@ -1,10 +1,9 @@  - Allure.XUnit.reporters + Allure.Xunit.reporters netcoreapp2.0;netstandard2.1;net5.0;net6.0 true - Allure.XUnit Shumakov Ivan Create beautiful reports from your xUnit.net tests. Allure-X-Color.png diff --git a/Allure.XUnit/AllureAttachments.cs b/Allure.XUnit/AllureAttachments.cs index a5dc19cc..286034ed 100644 --- a/Allure.XUnit/AllureAttachments.cs +++ b/Allure.XUnit/AllureAttachments.cs @@ -5,7 +5,7 @@ using Allure.Net.Commons; using HeyRed.Mime; -namespace Allure.XUnit +namespace Allure.Xunit { /// /// Decorates AllureLifecycle.Instance.AddAttachment method. Used to save attachments for reports. diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.XUnit/AllureMessageSink.cs index a86a1ac6..faf246eb 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.XUnit/AllureMessageSink.cs @@ -4,14 +4,13 @@ using System.Linq; using Allure.Net.Commons; using Allure.Net.Commons.TestPlan; -using Allure.Xunit; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { public class AllureMessageSink : DefaultRunnerReporterWithTypesMessageHandler diff --git a/Allure.XUnit/AllureRunnerReporter.cs b/Allure.XUnit/AllureRunnerReporter.cs index 894bd0de..06ae2956 100644 --- a/Allure.XUnit/AllureRunnerReporter.cs +++ b/Allure.XUnit/AllureRunnerReporter.cs @@ -3,7 +3,7 @@ #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { public class AllureRunnerReporter : IRunnerReporter { diff --git a/Allure.XUnit/AllureXunitConfiguration.cs b/Allure.XUnit/AllureXunitConfiguration.cs index 9c71b47c..9968f2ad 100644 --- a/Allure.XUnit/AllureXunitConfiguration.cs +++ b/Allure.XUnit/AllureXunitConfiguration.cs @@ -7,7 +7,7 @@ #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { internal class AllureXunitConfiguration : AllureConfiguration { diff --git a/Allure.XUnit/AllureXunitFacade.cs b/Allure.XUnit/AllureXunitFacade.cs index 2e1793cb..9c44c6eb 100644 --- a/Allure.XUnit/AllureXunitFacade.cs +++ b/Allure.XUnit/AllureXunitFacade.cs @@ -7,7 +7,7 @@ #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { public static class AllureXunitFacade { diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 68ae9736..79bfb22b 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -6,8 +6,6 @@ using Allure.Net.Commons; using Allure.Net.Commons.Functions; using Allure.Xunit.Attributes; -using Allure.XUnit; -using Allure.XUnit.Attributes; using Xunit; using Xunit.Abstractions; @@ -17,6 +15,9 @@ namespace Allure.Xunit { public static class AllureXunitHelper { + internal const string NS_OBSOLETE_MSG = + "The Allure.XUnit namespace is deprecated. Please, use Allure.Xunit instead"; + internal interface ITestResultAccessor { TestResultContainer TestResultContainer { get; set; } diff --git a/Allure.XUnit/AllureXunitPatcher.cs b/Allure.XUnit/AllureXunitPatcher.cs index 5c070861..f7fc4261 100644 --- a/Allure.XUnit/AllureXunitPatcher.cs +++ b/Allure.XUnit/AllureXunitPatcher.cs @@ -5,7 +5,7 @@ using Xunit.Abstractions; using Xunit.Sdk; -namespace Allure.XUnit; +namespace Allure.Xunit; internal static class AllureXunitPatcher { @@ -28,7 +28,7 @@ private static AllureMessageSink CurrentSink } } - public static void PatchXunit(IRunnerLogger runnerLogger) + internal static void PatchXunit(IRunnerLogger runnerLogger) { if (_isPatched) { diff --git a/Allure.XUnit/AllureXunitTestData.cs b/Allure.XUnit/AllureXunitTestData.cs index 2a0d3b18..ca51f77e 100644 --- a/Allure.XUnit/AllureXunitTestData.cs +++ b/Allure.XUnit/AllureXunitTestData.cs @@ -2,7 +2,7 @@ #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { class AllureXunitTestData { diff --git a/Allure.XUnit/Attachments.cs b/Allure.XUnit/Attachments.cs index 1063dfcd..fd0e96f0 100644 --- a/Allure.XUnit/Attachments.cs +++ b/Allure.XUnit/Attachments.cs @@ -1,10 +1,13 @@ +using System; +using System.ComponentModel; using System.Text; using Allure.Net.Commons; +using Allure.Xunit; using HeyRed.Mime; -namespace Allure.XUnit +namespace Allure.Xunit { - public abstract class Attachments + public static class Attachments { public static void Text(string name, string content) => Bytes(name, Encoding.UTF8.GetBytes(content), ".txt"); public static void Bytes(string name, byte[] content, string extension = "") => @@ -13,4 +16,21 @@ public static void File(string name, string path) => AllureApi.AddAttachment(path, name); public static void File(string fileName) => File(fileName, fileName); } +} + +namespace Allure.XUnit +{ + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] + public abstract class Attachments + { + public static void Text(string name, string content) => + Xunit.Attachments.Text(name, content); + public static void Bytes(string name, byte[] content, string extension = "") => + Xunit.Attachments.Bytes(name, content, extension); + public static void File(string name, string path) => + Xunit.Attachments.File(name, path); + public static void File(string fileName) => + Xunit.Attachments.File(fileName); + } } \ No newline at end of file diff --git a/Allure.XUnit/Attributes/AllureDescriptionAttribute.cs b/Allure.XUnit/Attributes/AllureDescriptionAttribute.cs index 902ebbe5..530e77a7 100644 --- a/Allure.XUnit/Attributes/AllureDescriptionAttribute.cs +++ b/Allure.XUnit/Attributes/AllureDescriptionAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureEpicAttribute.cs b/Allure.XUnit/Attributes/AllureEpicAttribute.cs index f56f018e..bdeadb3c 100644 --- a/Allure.XUnit/Attributes/AllureEpicAttribute.cs +++ b/Allure.XUnit/Attributes/AllureEpicAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureFeatureAttribute.cs b/Allure.XUnit/Attributes/AllureFeatureAttribute.cs index bf270b20..6452f047 100644 --- a/Allure.XUnit/Attributes/AllureFeatureAttribute.cs +++ b/Allure.XUnit/Attributes/AllureFeatureAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureIdAttribute.cs b/Allure.XUnit/Attributes/AllureIdAttribute.cs index a7509d78..df0e8536 100644 --- a/Allure.XUnit/Attributes/AllureIdAttribute.cs +++ b/Allure.XUnit/Attributes/AllureIdAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureIssueAttribute.cs b/Allure.XUnit/Attributes/AllureIssueAttribute.cs index 58d77c61..1dfe2047 100644 --- a/Allure.XUnit/Attributes/AllureIssueAttribute.cs +++ b/Allure.XUnit/Attributes/AllureIssueAttribute.cs @@ -1,6 +1,5 @@ using System; using Allure.Net.Commons; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureLabelAttribute.cs b/Allure.XUnit/Attributes/AllureLabelAttribute.cs index a25b7dc9..bd5d3f64 100644 --- a/Allure.XUnit/Attributes/AllureLabelAttribute.cs +++ b/Allure.XUnit/Attributes/AllureLabelAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureLinkAttribute.cs b/Allure.XUnit/Attributes/AllureLinkAttribute.cs index 5a10ac34..0082d4ad 100644 --- a/Allure.XUnit/Attributes/AllureLinkAttribute.cs +++ b/Allure.XUnit/Attributes/AllureLinkAttribute.cs @@ -1,6 +1,5 @@ using System; using Allure.Net.Commons; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureOwnerAttribute.cs b/Allure.XUnit/Attributes/AllureOwnerAttribute.cs index 75da76d9..b100b1ae 100644 --- a/Allure.XUnit/Attributes/AllureOwnerAttribute.cs +++ b/Allure.XUnit/Attributes/AllureOwnerAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs b/Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs index 61a60efe..342d6c7c 100644 --- a/Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs +++ b/Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureSeverityAttribute.cs b/Allure.XUnit/Attributes/AllureSeverityAttribute.cs index d55616f1..7eeffc3d 100644 --- a/Allure.XUnit/Attributes/AllureSeverityAttribute.cs +++ b/Allure.XUnit/Attributes/AllureSeverityAttribute.cs @@ -1,6 +1,5 @@ using System; using Allure.Net.Commons; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureStoryAttribute.cs b/Allure.XUnit/Attributes/AllureStoryAttribute.cs index 11203677..8c956727 100644 --- a/Allure.XUnit/Attributes/AllureStoryAttribute.cs +++ b/Allure.XUnit/Attributes/AllureStoryAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs b/Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs index 1de5f6fe..e94f0bc3 100644 --- a/Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs +++ b/Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureSuiteAttribute.cs b/Allure.XUnit/Attributes/AllureSuiteAttribute.cs index 3b21b801..4f8d49fb 100644 --- a/Allure.XUnit/Attributes/AllureSuiteAttribute.cs +++ b/Allure.XUnit/Attributes/AllureSuiteAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/AllureTagAttribute.cs b/Allure.XUnit/Attributes/AllureTagAttribute.cs index 41cf05bc..70fb96d3 100644 --- a/Allure.XUnit/Attributes/AllureTagAttribute.cs +++ b/Allure.XUnit/Attributes/AllureTagAttribute.cs @@ -1,5 +1,4 @@ using System; -using Allure.XUnit.Attributes; namespace Allure.Xunit.Attributes { diff --git a/Allure.XUnit/Attributes/IAllureInfo.cs b/Allure.XUnit/Attributes/IAllureInfo.cs index 91ebe3ad..97ab9df1 100644 --- a/Allure.XUnit/Attributes/IAllureInfo.cs +++ b/Allure.XUnit/Attributes/IAllureInfo.cs @@ -1,4 +1,4 @@ -namespace Allure.XUnit.Attributes +namespace Allure.Xunit.Attributes { internal interface IAllureInfo { diff --git a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs index 3e9d03d1..b20936b3 100644 --- a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs @@ -1,8 +1,22 @@ +using System; +using System.ComponentModel; using Allure.Net.Commons.Steps; using Allure.Xunit; +namespace Allure.Xunit.Attributes.Steps +{ + public class AllureAfterAttribute : AllureStepAttributes.AbstractAfterAttribute + { + public AllureAfterAttribute(string name = null) : base(name) + { + } + } +} + namespace Allure.XUnit.Attributes.Steps { + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] public class AllureAfterAttribute : AllureStepAttributes.AbstractAfterAttribute { public AllureAfterAttribute(string name = null) : base(name) diff --git a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs index 4591b331..eda9da77 100644 --- a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs @@ -1,7 +1,22 @@ +using System; +using System.ComponentModel; using Allure.Net.Commons.Steps; +using Allure.Xunit; + +namespace Allure.Xunit.Attributes.Steps +{ + public class AllureBeforeAttribute : AllureStepAttributes.AbstractBeforeAttribute + { + public AllureBeforeAttribute(string name = null) : base(name) + { + } + } +} namespace Allure.XUnit.Attributes.Steps { + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] public class AllureBeforeAttribute : AllureStepAttributes.AbstractBeforeAttribute { public AllureBeforeAttribute(string name = null) : base(name) diff --git a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs index b5a6a333..e679574c 100644 --- a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs @@ -1,7 +1,22 @@ +using System; +using System.ComponentModel; using Allure.Net.Commons.Steps; +using Allure.Xunit; + +namespace Allure.Xunit.Attributes.Steps +{ + public class AllureStepAttribute : AllureStepAttributes.AbstractStepAttribute + { + public AllureStepAttribute(string name = null) : base(name) + { + } + } +} namespace Allure.XUnit.Attributes.Steps { + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] public class AllureStepAttribute : AllureStepAttributes.AbstractStepAttribute { public AllureStepAttribute(string name = null) : base(name) diff --git a/Allure.XUnit/Attributes/Steps/NameAttribute.cs b/Allure.XUnit/Attributes/Steps/NameAttribute.cs index 1a266294..c8fe08e7 100644 --- a/Allure.XUnit/Attributes/Steps/NameAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/NameAttribute.cs @@ -1,7 +1,22 @@ +using System; +using System.ComponentModel; using Allure.Net.Commons.Steps; +using Allure.Xunit; + +namespace Allure.Xunit.Attributes.Steps +{ + public class NameAttribute : AbstractNameAttribute + { + public NameAttribute(string name) : base(name) + { + } + } +} namespace Allure.XUnit.Attributes.Steps { + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] public class NameAttribute : AbstractNameAttribute { public NameAttribute(string name) : base(name) diff --git a/Allure.XUnit/Attributes/Steps/SkipAttribute.cs b/Allure.XUnit/Attributes/Steps/SkipAttribute.cs index f036b944..187934dd 100644 --- a/Allure.XUnit/Attributes/Steps/SkipAttribute.cs +++ b/Allure.XUnit/Attributes/Steps/SkipAttribute.cs @@ -1,7 +1,19 @@ +using System; +using System.ComponentModel; using Allure.Net.Commons.Steps; +using Allure.Xunit; + +namespace Allure.Xunit.Attributes.Steps +{ + public class SkipAttribute : AbstractSkipAttribute + { + } +} namespace Allure.XUnit.Attributes.Steps { + [Obsolete(AllureXunitHelper.NS_OBSOLETE_MSG)] + [EditorBrowsable(EditorBrowsableState.Never)] public class SkipAttribute : AbstractSkipAttribute { } diff --git a/Allure.XUnit/ComposedMessageSink.cs b/Allure.XUnit/ComposedMessageSink.cs index 66410aff..15113b9d 100644 --- a/Allure.XUnit/ComposedMessageSink.cs +++ b/Allure.XUnit/ComposedMessageSink.cs @@ -2,7 +2,7 @@ using Xunit; using Xunit.Abstractions; -namespace Allure.XUnit +namespace Allure.Xunit { internal class ComposedMessageSink : IMessageSink, IMessageSinkWithTypes { diff --git a/Allure.XUnit/README.md b/Allure.XUnit/README.md index 64a5e79e..f11c5217 100644 --- a/Allure.XUnit/README.md +++ b/Allure.XUnit/README.md @@ -1,18 +1,18 @@ -# Allure.XUnit +# Allure.Xunit -[![Nuget](https://img.shields.io/nuget/v/Allure.XUnit?style=flat)](https://www.nuget.org/packages/Allure.XUnit) -[![Nuget pre](https://img.shields.io/nuget/vpre/Allure.XUnit?style=flat)](https://www.nuget.org/packages/Allure.XUnit) +[![Nuget](https://img.shields.io/nuget/v/Allure.Xunit?style=flat)](https://www.nuget.org/packages/Allure.Xunit) +[![Nuget pre](https://img.shields.io/nuget/vpre/Allure.Xunit?style=flat)](https://www.nuget.org/packages/Allure.Xunit) ![Nuget downloads](https://img.shields.io/nuget/dt/allure.xunit?label=downloads&style=flat) > An Allure adapter for [xUnit.net](https://xunit.net/). -Allure.XUnit supports .NET Core 2.0 or later, or any .NET runtime that +Allure Xunit supports .NET Core 2.0 or later, or any .NET runtime that implements .NET Standard 2.1. ## Quick start -Install the Allure.XUnit package and run the tests normally. In many cases +Install the Allure.Xunit package and run the tests normally. In many cases allure should start automatically. The result files are created in the `allure-results` directory in the target directory. If that didn't happen, check out the `Running tests in a CI pipeline` section. @@ -36,13 +36,13 @@ The AllureXunit and AllureXunitTheory attributes might be removed in future rele ### Allure.XUnit.StepExtensions deprecation There is no more need to use separate Allure.XUnit.StepExtensions package. You should remove it from dependencies and use attributes from -[Allure.XUnit.Attributes.Steps namespace](Attributes/Steps) directly. +[Allure.Xunit.Attributes.Steps namespace](Attributes/Steps) directly. -### Allure.Xunit.Steps deprecation - -The new `Allure.Net.Commons.AllureApi` facade class was designed specificially -for test authors to enhance the Allure report. Prefer using functions in this -class over the ones from `Allure.Xunit.Steps`. +### Namespace change +Previously, the package used a mix of `Allure.Xunit` and `Allure.XUnit` +namespaces. Starting from 2.12.0, you should only use `Allure.Xunit`. Some parts +of the public API are still accessible through the old namespace, but that +access is deprecated now and will be removed in the future. ## Known issues and limitations diff --git a/Allure.XUnit/TypeExtensions.cs b/Allure.XUnit/TypeExtensions.cs index 4951c325..be70a662 100644 --- a/Allure.XUnit/TypeExtensions.cs +++ b/Allure.XUnit/TypeExtensions.cs @@ -3,7 +3,7 @@ using System.Reflection; using System.Text; -namespace Allure.XUnit +namespace Allure.Xunit { internal static class TypeExtensions { diff --git a/README.md b/README.md index 0679ae57..0b0ca3bb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ | Library | Examples | Author | Release | Preview build | |:-----------------------------------------|:---------------------------------:|:----------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:| -| [Allure.XUnit](Allure.XUnit) | [Examples](Allure.XUnit.Examples) | [Shumakov Ivan](https://github.com/IvanWR1995) | [![Nuget](https://img.shields.io/nuget/v/Allure.XUnit)](https://www.nuget.org/packages/Allure.XUnit/) | [![Nuget](https://img.shields.io/nuget/vpre/Allure.XUnit)](https://www.nuget.org/packages/Allure.XUnit/) | +| [Allure.Xunit](Allure.Xunit) | [Examples](Allure.Xunit.Examples) | [Shumakov Ivan](https://github.com/IvanWR1995) | [![Nuget](https://img.shields.io/nuget/v/Allure.Xunit)](https://www.nuget.org/packages/Allure.Xunit/) | [![Nuget](https://img.shields.io/nuget/vpre/Allure.Xunit)](https://www.nuget.org/packages/Allure.Xunit/) | | [Allure.NUnit](Allure.NUnit) | [Examples](Allure.NUnit.Examples) | [Nick Chursin](https://github.com/unickq) | [![Nuget](https://img.shields.io/nuget/v/Allure.NUnit)](https://www.nuget.org/packages/Allure.NUnit/) | [![Nuget](https://img.shields.io/nuget/vpre/Allure.NUnit)](https://www.nuget.org/packages/Allure.NUnit/) | | [Allure.SpecFlow](Allure.SpecFlowPlugin) | [Examples](Allure.Features) | Alexander Bakanov | [![Nuget](https://img.shields.io/nuget/v/SpecFlow.Allure)](https://www.nuget.org/packages/SpecFlow.Allure/) | [![Nuget](https://img.shields.io/nuget/v/Allure.SpecFlow)](https://www.nuget.org/packages/Allure.SpecFlow/) | diff --git a/allure-csharp.sln b/allure-csharp.sln index 0d6944f1..52b3caa2 100644 --- a/allure-csharp.sln +++ b/allure-csharp.sln @@ -19,9 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.Features", "Allure.F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "allure-xunit", "allure-xunit", "{138A76FC-B163-423C-8FF8-D374F1C7EC2F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.XUnit", "Allure.XUnit\Allure.XUnit.csproj", "{D278CE6B-F3D1-4FEF-BE5F-5AC6F6C53879}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.Xunit", "Allure.Xunit\Allure.Xunit.csproj", "{D278CE6B-F3D1-4FEF-BE5F-5AC6F6C53879}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.XUnit.Examples", "Allure.XUnit.Examples\Allure.XUnit.Examples.csproj", "{38CF463E-F564-477D-A853-407F0648E0DD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Allure.Xunit.Examples", "Allure.Xunit.Examples\Allure.Xunit.Examples.csproj", "{38CF463E-F564-477D-A853-407F0648E0DD}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "allure-nunit", "allure-nunit", "{D0D75FDF-4884-4AC1-868F-B3F248CB74ED}" EndProject From e83143ea44899aa08a4a70b9f2d494244014a641 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:00:54 +0700 Subject: [PATCH 07/13] Remove obsolete API from Allure.Xunit - using-style steps/fixtures: - Allure.Xunit.AllureBefore - Allure.Xunit.AllureAfter - Allure.Xunit.AllureStep - Allure.Xunit.AllureStepBase - Async attachment functions in Allure.Xunit.AllureAttachments - Unused internal methods of AllureXunitHelper that had accidentally leaked into public API: - StartTestContainer - StartTestCase - MarkTestCaseAsFailedOrBroken - MarkTestCaseAsPassed - MarkTestCaseAsSkipped - FinishTestCase - The Allure.Xunit.Steps class - AllureXunitAttribute and AllureXunitTheoryAttribute (not used anymore) --- Allure.XUnit/AllureAfter.cs | 14 --- Allure.XUnit/AllureAttachments.cs | 48 --------- Allure.XUnit/AllureBefore.cs | 14 --- Allure.XUnit/AllureStep.cs | 14 --- Allure.XUnit/AllureStepBase.cs | 57 ----------- Allure.XUnit/AllureXunitHelper.cs | 98 ------------------- .../Attributes/AllureXunitAttribute.cs | 12 --- .../Attributes/AllureXunitTheoryAttribute.cs | 12 --- Allure.XUnit/README.md | 10 +- Allure.XUnit/Steps.cs | 12 --- 10 files changed, 1 insertion(+), 290 deletions(-) delete mode 100644 Allure.XUnit/AllureAfter.cs delete mode 100644 Allure.XUnit/AllureAttachments.cs delete mode 100644 Allure.XUnit/AllureBefore.cs delete mode 100644 Allure.XUnit/AllureStep.cs delete mode 100644 Allure.XUnit/AllureStepBase.cs delete mode 100644 Allure.XUnit/Attributes/AllureXunitAttribute.cs delete mode 100644 Allure.XUnit/Attributes/AllureXunitTheoryAttribute.cs delete mode 100644 Allure.XUnit/Steps.cs diff --git a/Allure.XUnit/AllureAfter.cs b/Allure.XUnit/AllureAfter.cs deleted file mode 100644 index fb1134d5..00000000 --- a/Allure.XUnit/AllureAfter.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Allure.Net.Commons; - -namespace Allure.Xunit -{ - public sealed class AllureAfter : AllureStepBase - { - [Obsolete("Use AllureAfterAttribute")] - public AllureAfter(string name) - { - ExtendedApi.StartAfterFixture(name); - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/AllureAttachments.cs b/Allure.XUnit/AllureAttachments.cs deleted file mode 100644 index 286034ed..00000000 --- a/Allure.XUnit/AllureAttachments.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; -using Allure.Net.Commons; -using HeyRed.Mime; - -namespace Allure.Xunit -{ - /// - /// Decorates AllureLifecycle.Instance.AddAttachment method. Used to save attachments for reports. - /// - /// Use instead. - /// After 2.9.1 there is no reason to use methods returning async Task. - - [Obsolete("Use Attachments class instead. All async operations will be removed in future release 2.10")] - public class AllureAttachments - { - [Obsolete] - public static async Task Text(string name, string content) => - await Bytes(name, Encoding.UTF8.GetBytes(content), ".txt"); - - [Obsolete] - public static async Task Bytes(string name, byte[] content, string extension) => - await AddAttachment(name, MimeTypesMap.GetMimeType(extension), content, extension); - - [Obsolete] - public static Task File(string fileName) - { - return File(fileName, fileName); - } - - [Obsolete] - public static async Task File(string attachmentName, string fileName) - { - var content = await System.IO.File.ReadAllBytesAsync(fileName); - var extension = Path.GetExtension(fileName); - await Bytes(attachmentName, content, extension); - } - - [Obsolete] - public static Task AddAttachment(string name, string type, byte[] content, string fileExtension) - { - AllureApi.AddAttachment(name, type, content, fileExtension); - return Task.CompletedTask; - } - } -} diff --git a/Allure.XUnit/AllureBefore.cs b/Allure.XUnit/AllureBefore.cs deleted file mode 100644 index eed8d253..00000000 --- a/Allure.XUnit/AllureBefore.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Allure.Net.Commons; - -namespace Allure.Xunit -{ - public sealed class AllureBefore : AllureStepBase - { - [Obsolete("Use AllureBeforeAttribute")] - public AllureBefore(string name) - { - ExtendedApi.StartBeforeFixture(name); - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/AllureStep.cs b/Allure.XUnit/AllureStep.cs deleted file mode 100644 index 1a5b2889..00000000 --- a/Allure.XUnit/AllureStep.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Allure.Net.Commons; - -namespace Allure.Xunit -{ - public sealed class AllureStep : AllureStepBase - { - [Obsolete("Use AllureStepAttribute")] - public AllureStep(string name) - { - ExtendedApi.StartStep(name); - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/AllureStepBase.cs b/Allure.XUnit/AllureStepBase.cs deleted file mode 100644 index 732518a9..00000000 --- a/Allure.XUnit/AllureStepBase.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using Allure.Net.Commons; - -#if NETCOREAPP3_0_OR_GREATER -using System.Runtime.CompilerServices; -#endif - -namespace Allure.Xunit -{ - public abstract class AllureStepBase : IDisposable where T : AllureStepBase - { - protected AllureStepBase() { } - - public void Dispose() - { -#if NETCOREAPP3_0_OR_GREATER - var failed = Marshal.GetExceptionPointers() != IntPtr.Zero; -#else - // The call is guarded, so it's safe to ignore the deprecation warning -#pragma warning disable CS0618 - var failed = Marshal.GetExceptionCode() != 0; -#pragma warning restore CS0618 -#endif - if (failed) - { - ExtendedApi.FailStep(); - } - else - { - ExtendedApi.PassStep(); - } - } - - [Obsolete("For named parameters use NameAttribute; For skipped parameters use SkipAttribute")] - public T SetParameter(string name, object value) - { - AllureLifecycle.Instance.UpdateStep( - result => - { - result.parameters ??= new List(); - result.parameters.Add(new Parameter { name = name, value = value?.ToString() }); - } - ); - return (T) this; - } - -#if NETCOREAPP3_0_OR_GREATER - [Obsolete("For named parameters use NameAttribute; For skipped parameters use SkipAttribute")] - public T SetParameter(object value, [CallerArgumentExpression("value")] string name = null) - { - return SetParameter(name, value); - } -#endif - } -} \ No newline at end of file diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 79bfb22b..44821527 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using Allure.Net.Commons; @@ -400,102 +399,5 @@ static string BuildFullName(ITestCase testCase) parametersSegment ); } - - #region Obsolete public methods - const string OBS_MSG_UNINTENDED_PUBLIC = - "This method wasn't supposed to be in the public API. It's not " + - "relevant anymore and will be removed in a future release"; - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void StartTestContainer( - ITestCaseStarting testCaseStarting - ) - { - var testCase = testCaseStarting.TestCase; - if (testCase is not ITestResultAccessor testResults) - { - return; - } - - testResults.TestResultContainer = StartNewAllureContainer( - testCaseStarting.TestClass.Class.Name - ); - } - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void StartTestCase(ITestCaseMessage testCaseMessage) - { - var testCase = testCaseMessage.TestCase; - if (testCase is not ITestResultAccessor testResults) - { - return; - } - - testResults.TestResult = CreateTestResultByTestCase(testCase); - AllureLifecycle.Instance.StartTestCase(testResults.TestResult); - ApplyTestParameters( - testCase.TestMethod.Method.GetParameters(), - testCase.TestMethodArguments - ); - } - - static TestResult CreateTestResultByTestCase(ITestCase testCase) => - CreateTestResult(testCase, testCase.DisplayName); - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void MarkTestCaseAsFailedOrBroken(ITestFailed testFailed) - { - if (testFailed.TestCase is not ITestResultAccessor) - { - return; - } - - ApplyTestFailure(testFailed); - } - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void MarkTestCaseAsPassed(ITestPassed testPassed) - { - if (testPassed.TestCase is not ITestResultAccessor) - { - return; - } - - ApplyTestSuccess(testPassed); - } - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void MarkTestCaseAsSkipped( - ITestCaseMessage testCaseMessage - ) - { - var testCase = testCaseMessage.TestCase; - if (testCase is not ITestResultAccessor testResults) - { - return; - } - - ApplyTestSkip(testResults.TestResult, testCase.SkipReason); - } - - [Obsolete(OBS_MSG_UNINTENDED_PUBLIC)] - [EditorBrowsable(EditorBrowsableState.Never)] - public static void FinishTestCase(ITestCaseMessage testCaseMessage) - { - var testCase = testCaseMessage.TestCase; - if (testCase is not ITestResultAccessor) - { - return; - } - - ReportCurrentTestCase(); - ReportCurrentTestContainer(); - } - #endregion } } \ No newline at end of file diff --git a/Allure.XUnit/Attributes/AllureXunitAttribute.cs b/Allure.XUnit/Attributes/AllureXunitAttribute.cs deleted file mode 100644 index 69d6843b..00000000 --- a/Allure.XUnit/Attributes/AllureXunitAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.ComponentModel; -using Xunit; - -namespace Allure.Xunit.Attributes -{ - [Obsolete("Use [Xunit.Fact] instead")] - [EditorBrowsable(EditorBrowsableState.Never)] - public class AllureXunitAttribute : FactAttribute - { - } -} \ No newline at end of file diff --git a/Allure.XUnit/Attributes/AllureXunitTheoryAttribute.cs b/Allure.XUnit/Attributes/AllureXunitTheoryAttribute.cs deleted file mode 100644 index f71337f7..00000000 --- a/Allure.XUnit/Attributes/AllureXunitTheoryAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.ComponentModel; -using Xunit; - -namespace Allure.Xunit.Attributes -{ - [Obsolete("Use [Xunit.Theory] instead")] - [EditorBrowsable(EditorBrowsableState.Never)] - public class AllureXunitTheoryAttribute : TheoryAttribute - { - } -} \ No newline at end of file diff --git a/Allure.XUnit/README.md b/Allure.XUnit/README.md index f11c5217..5204c2a8 100644 --- a/Allure.XUnit/README.md +++ b/Allure.XUnit/README.md @@ -25,15 +25,7 @@ Some examples are available [here](https://github.com/allure-framework/allure-cs ## Notes -### AllureXunit and AllureXunitTheory deprecation -Previously all test methods had to be marked with the AllureXunit or -AllureXunitTheory attributes. There is no such need anymore. -These attributes are still supported, but we advice you to use the built-in -Fact and Theory attributes instead. - -The AllureXunit and AllureXunitTheory attributes might be removed in future releases. - -### Allure.XUnit.StepExtensions deprecation +### Allure.Xunit.StepExtensions deprecation There is no more need to use separate Allure.XUnit.StepExtensions package. You should remove it from dependencies and use attributes from [Allure.Xunit.Attributes.Steps namespace](Attributes/Steps) directly. diff --git a/Allure.XUnit/Steps.cs b/Allure.XUnit/Steps.cs deleted file mode 100644 index a969e25a..00000000 --- a/Allure.XUnit/Steps.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.ComponentModel; - -namespace Allure.Xunit -{ - [Obsolete("Members of this class are now a part of the end user API represented by the AllureApi facade. " + - "Please, use the Allure.Net.Commons.Allure class instead.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public abstract class Steps - { - } -} \ No newline at end of file From 3d8d0e364cd52996af21bdc42dbc6a9ad5b8233e Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:01:10 +0700 Subject: [PATCH 08/13] Fix allure-xunit README --- Allure.XUnit/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Allure.XUnit/README.md b/Allure.XUnit/README.md index 5204c2a8..54813d8e 100644 --- a/Allure.XUnit/README.md +++ b/Allure.XUnit/README.md @@ -19,15 +19,15 @@ If that didn't happen, check out the `Running tests in a CI pipeline` section. ## Further readings -Learn more from [the documentation for Allure NUnit](https://allurereport.org/docs/nunit/). +Learn more from [the documentation for Allure Xunit](https://allurereport.org/docs/xunit/). -Some examples are available [here](https://github.com/allure-framework/allure-csharp/tree/main/Allure.XUnit.Examples). +Some examples are available [here](https://github.com/allure-framework/allure-csharp/tree/main/Allure.Xunit.Examples). ## Notes ### Allure.Xunit.StepExtensions deprecation There is no more need to use separate Allure.XUnit.StepExtensions package. You -should remove it from dependencies and use attributes from +should uninstall it and use attributes from [Allure.Xunit.Attributes.Steps namespace](Attributes/Steps) directly. ### Namespace change @@ -53,8 +53,8 @@ You may also install Rosetta via the CLI: We rely on Harmony that in turn uses MonoMod.Core to: -1. Report arguments of theories in rare case they aren't reported by xUnit.net itself. -2. Implement selectie run. +1. Report arguments of theories in case they aren't reported by xUnit.net itself. +2. Implement selectie run (test plans). Those features are unavailable on ARM64 due to limitations of MonoMod.Core. Additionally, they might not work in some other rare circumstances. From b50c9501ffb1ba4b9a5ea94067710ca206e5795c Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:02:02 +0700 Subject: [PATCH 09/13] Make internal API hidden from public --- Allure.XUnit/AllureMessageSink.cs | 4 ++-- Allure.XUnit/AllureXunitFacade.cs | 4 ++-- Allure.XUnit/AllureXunitHelper.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.XUnit/AllureMessageSink.cs index faf246eb..cf901f9a 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.XUnit/AllureMessageSink.cs @@ -12,7 +12,7 @@ namespace Allure.Xunit { - public class AllureMessageSink : + class AllureMessageSink : DefaultRunnerReporterWithTypesMessageHandler { static AllureTestPlan TestPlan @@ -224,6 +224,6 @@ void LogUnreportedTheoryArgs(string testName) static bool IsStaticTestMethod(ITestMethodMessage message) => message.TestMethod.Method.IsStatic; - public static AllureMessageSink? CurrentSink { get; private set; } + internal static AllureMessageSink? CurrentSink { get; private set; } } } \ No newline at end of file diff --git a/Allure.XUnit/AllureXunitFacade.cs b/Allure.XUnit/AllureXunitFacade.cs index 9c44c6eb..3a4a6518 100644 --- a/Allure.XUnit/AllureXunitFacade.cs +++ b/Allure.XUnit/AllureXunitFacade.cs @@ -9,9 +9,9 @@ namespace Allure.Xunit { - public static class AllureXunitFacade + static class AllureXunitFacade { - public static IMessageSink CreateAllureXunitMessageHandler( + internal static IMessageSink CreateAllureXunitMessageHandler( IRunnerLogger logger ) { diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 44821527..68d432ba 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -12,7 +12,7 @@ namespace Allure.Xunit { - public static class AllureXunitHelper + static class AllureXunitHelper { internal const string NS_OBSOLETE_MSG = "The Allure.XUnit namespace is deprecated. Please, use Allure.Xunit instead"; From d424840de59662c7560518ffc6a03c04c8188537 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:13:22 +0700 Subject: [PATCH 10/13] Make second reporter resolution more strict (#412) Now, it only considers assemblies with names matching the *reporters* pattern. --- Allure.XUnit/AllureXunitFacade.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Allure.XUnit/AllureXunitFacade.cs b/Allure.XUnit/AllureXunitFacade.cs index 3a4a6518..2c82bdb0 100644 --- a/Allure.XUnit/AllureXunitFacade.cs +++ b/Allure.XUnit/AllureXunitFacade.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; +using System.Text.RegularExpressions; using Xunit; using Xunit.Abstractions; @@ -11,6 +11,7 @@ namespace Allure.Xunit { static class AllureXunitFacade { + static readonly Regex REPORTER_ASSEMBLY_PATTERN = new(@".*reporters.*"); internal static IMessageSink CreateAllureXunitMessageHandler( IRunnerLogger logger ) @@ -89,7 +90,9 @@ select reporter static IEnumerable GetReporters() => from assembly in AppDomain.CurrentDomain.GetAssemblies() - where IsPotentialReporterAssembly(assembly) + where IsPotentialReporterAssembly( + assembly.GetName()?.Name + ) from type in assembly.GetTypes() where IsReporterType(type) select Activator.CreateInstance(type) as IRunnerReporter; @@ -99,11 +102,13 @@ where IsReporterType(type) /// skipped as well, because there is only one reporter there and it /// has already been picked at the time this code is run. /// - static bool IsPotentialReporterAssembly(Assembly assembly) => - assembly?.FullName is not null + static bool IsPotentialReporterAssembly(string? name) => + name is not null + && + REPORTER_ASSEMBLY_PATTERN.IsMatch(name) && ASSEMBLY_PREFIXES_TO_SKIP.All( - a => !assembly.FullName.StartsWith( + a => !name.StartsWith( a, StringComparison.OrdinalIgnoreCase ) From cd3e89b29cf806b43d66b520d4b32469c9968999 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:32:36 +0700 Subject: [PATCH 11/13] Set Allure.Xunit's TFMs to netstandard2.0 and netcoreapp3.1 --- Allure.XUnit/Allure.XUnit.csproj | 2 +- Allure.XUnit/AllureMessageSink.cs | 2 +- Allure.XUnit/AllureXunitHelper.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Allure.XUnit/Allure.XUnit.csproj b/Allure.XUnit/Allure.XUnit.csproj index c3dd6797..9af2ec8d 100644 --- a/Allure.XUnit/Allure.XUnit.csproj +++ b/Allure.XUnit/Allure.XUnit.csproj @@ -2,7 +2,7 @@ Allure.Xunit.reporters - netcoreapp2.0;netstandard2.1;net5.0;net6.0 + netstandard2.0;netcoreapp3.1 true Shumakov Ivan Create beautiful reports from your xUnit.net tests. diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.XUnit/AllureMessageSink.cs index cf901f9a..a62332cb 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.XUnit/AllureMessageSink.cs @@ -161,7 +161,7 @@ void OnTestFinished(MessageHandlerArgs args) }); } - this.allureTestData.Remove(test, out _); + this.allureTestData.TryRemove(test, out _); } AllureXunitTestData GetOrCreateTestData(ITest test) diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 68d432ba..71d18afc 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -66,8 +66,8 @@ internal static void StartAllureTestCase( internal static void ApplyTestFailure(IFailureInformation failure) { - var trace = string.Join('\n', failure.StackTraces); - var message = string.Join('\n', failure.Messages); + var trace = string.Join("\n", failure.StackTraces); + var message = string.Join("\n", failure.Messages); var status = failure.ExceptionTypes.Any( exceptionType => !exceptionType.StartsWith("Xunit.Sdk.") ) ? Status.broken : Status.failed; From cbd6378129c4d271c755590d1bd5cf3f397b4208 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:33:05 +0700 Subject: [PATCH 12/13] Remove redundant code from AllureXunitHelper --- Allure.XUnit/AllureXunitHelper.cs | 41 ------------------------------- 1 file changed, 41 deletions(-) diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.XUnit/AllureXunitHelper.cs index 71d18afc..1f7fc7b1 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.XUnit/AllureXunitHelper.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Allure.Net.Commons; using Allure.Net.Commons.Functions; @@ -17,36 +16,6 @@ static class AllureXunitHelper internal const string NS_OBSOLETE_MSG = "The Allure.XUnit namespace is deprecated. Please, use Allure.Xunit instead"; - internal interface ITestResultAccessor - { - TestResultContainer TestResultContainer { get; set; } - TestResult TestResult { get; set; } - } - - static AllureXunitHelper() - { - const string allureConfigEnvVariable = "ALLURE_CONFIG"; - const string allureConfigName = "allureConfig.json"; - - var allureConfigPath = Environment.GetEnvironmentVariable( - allureConfigEnvVariable - ); - if (!string.IsNullOrEmpty(allureConfigPath)) - { - return; - } - - allureConfigPath = Path.Combine( - AppDomain.CurrentDomain.BaseDirectory, - allureConfigName - ); - - Environment.SetEnvironmentVariable( - allureConfigEnvVariable, - allureConfigPath - ); - } - internal static TestResultContainer StartNewAllureContainer( string className ) @@ -178,16 +147,6 @@ string displayName return testResult; } - static void ApplyTestSkip( - TestResult testResult, - string reason - ) - { - var statusDetails = testResult.statusDetails ??= new(); - statusDetails.message = reason; - testResult.status = Status.skipped; - } - static void AddDistinct( this List diff --git a/Allure.XUnit.Examples/ExampleParameterisedTests.cs b/Allure.Xunit.Examples/ExampleParameterisedTests.cs similarity index 100% rename from Allure.XUnit.Examples/ExampleParameterisedTests.cs rename to Allure.Xunit.Examples/ExampleParameterisedTests.cs diff --git a/Allure.XUnit.Examples/ExampleStepAttributes.cs b/Allure.Xunit.Examples/ExampleStepAttributes.cs similarity index 100% rename from Allure.XUnit.Examples/ExampleStepAttributes.cs rename to Allure.Xunit.Examples/ExampleStepAttributes.cs diff --git a/Allure.XUnit.Examples/ExampleUnitTests.cs b/Allure.Xunit.Examples/ExampleUnitTests.cs similarity index 100% rename from Allure.XUnit.Examples/ExampleUnitTests.cs rename to Allure.Xunit.Examples/ExampleUnitTests.cs diff --git a/Allure.XUnit.Examples/TestData/MyTestClass.cs b/Allure.Xunit.Examples/TestData/MyTestClass.cs similarity index 100% rename from Allure.XUnit.Examples/TestData/MyTestClass.cs rename to Allure.Xunit.Examples/TestData/MyTestClass.cs diff --git a/Allure.XUnit.Examples/TestData/TestClassData.cs b/Allure.Xunit.Examples/TestData/TestClassData.cs similarity index 100% rename from Allure.XUnit.Examples/TestData/TestClassData.cs rename to Allure.Xunit.Examples/TestData/TestClassData.cs diff --git a/Allure.XUnit.Examples/TestData/TestDataGenerators.cs b/Allure.Xunit.Examples/TestData/TestDataGenerators.cs similarity index 100% rename from Allure.XUnit.Examples/TestData/TestDataGenerators.cs rename to Allure.Xunit.Examples/TestData/TestDataGenerators.cs diff --git a/Allure.XUnit.Examples/allureConfig.json b/Allure.Xunit.Examples/allureConfig.json similarity index 100% rename from Allure.XUnit.Examples/allureConfig.json rename to Allure.Xunit.Examples/allureConfig.json diff --git a/Allure.XUnit/Allure.XUnit.csproj b/Allure.Xunit/Allure.Xunit.csproj similarity index 100% rename from Allure.XUnit/Allure.XUnit.csproj rename to Allure.Xunit/Allure.Xunit.csproj diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.Xunit/AllureMessageSink.cs similarity index 100% rename from Allure.XUnit/AllureMessageSink.cs rename to Allure.Xunit/AllureMessageSink.cs diff --git a/Allure.XUnit/AllureRunnerReporter.cs b/Allure.Xunit/AllureRunnerReporter.cs similarity index 100% rename from Allure.XUnit/AllureRunnerReporter.cs rename to Allure.Xunit/AllureRunnerReporter.cs diff --git a/Allure.XUnit/AllureXunitConfiguration.cs b/Allure.Xunit/AllureXunitConfiguration.cs similarity index 100% rename from Allure.XUnit/AllureXunitConfiguration.cs rename to Allure.Xunit/AllureXunitConfiguration.cs diff --git a/Allure.XUnit/AllureXunitFacade.cs b/Allure.Xunit/AllureXunitFacade.cs similarity index 100% rename from Allure.XUnit/AllureXunitFacade.cs rename to Allure.Xunit/AllureXunitFacade.cs diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.Xunit/AllureXunitHelper.cs similarity index 100% rename from Allure.XUnit/AllureXunitHelper.cs rename to Allure.Xunit/AllureXunitHelper.cs diff --git a/Allure.XUnit/AllureXunitPatcher.cs b/Allure.Xunit/AllureXunitPatcher.cs similarity index 100% rename from Allure.XUnit/AllureXunitPatcher.cs rename to Allure.Xunit/AllureXunitPatcher.cs diff --git a/Allure.XUnit/AllureXunitTestData.cs b/Allure.Xunit/AllureXunitTestData.cs similarity index 100% rename from Allure.XUnit/AllureXunitTestData.cs rename to Allure.Xunit/AllureXunitTestData.cs diff --git a/Allure.XUnit/Attachments.cs b/Allure.Xunit/Attachments.cs similarity index 100% rename from Allure.XUnit/Attachments.cs rename to Allure.Xunit/Attachments.cs diff --git a/Allure.XUnit/Attributes/AllureAttribute.cs b/Allure.Xunit/Attributes/AllureAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureAttribute.cs rename to Allure.Xunit/Attributes/AllureAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureDescriptionAttribute.cs b/Allure.Xunit/Attributes/AllureDescriptionAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureDescriptionAttribute.cs rename to Allure.Xunit/Attributes/AllureDescriptionAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureEpicAttribute.cs b/Allure.Xunit/Attributes/AllureEpicAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureEpicAttribute.cs rename to Allure.Xunit/Attributes/AllureEpicAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureFeatureAttribute.cs b/Allure.Xunit/Attributes/AllureFeatureAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureFeatureAttribute.cs rename to Allure.Xunit/Attributes/AllureFeatureAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureIdAttribute.cs b/Allure.Xunit/Attributes/AllureIdAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureIdAttribute.cs rename to Allure.Xunit/Attributes/AllureIdAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureIssueAttribute.cs b/Allure.Xunit/Attributes/AllureIssueAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureIssueAttribute.cs rename to Allure.Xunit/Attributes/AllureIssueAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureLabelAttribute.cs b/Allure.Xunit/Attributes/AllureLabelAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureLabelAttribute.cs rename to Allure.Xunit/Attributes/AllureLabelAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureLinkAttribute.cs b/Allure.Xunit/Attributes/AllureLinkAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureLinkAttribute.cs rename to Allure.Xunit/Attributes/AllureLinkAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureOwnerAttribute.cs b/Allure.Xunit/Attributes/AllureOwnerAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureOwnerAttribute.cs rename to Allure.Xunit/Attributes/AllureOwnerAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs b/Allure.Xunit/Attributes/AllureParentSuiteAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureParentSuiteAttribute.cs rename to Allure.Xunit/Attributes/AllureParentSuiteAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureSeverityAttribute.cs b/Allure.Xunit/Attributes/AllureSeverityAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureSeverityAttribute.cs rename to Allure.Xunit/Attributes/AllureSeverityAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureStoryAttribute.cs b/Allure.Xunit/Attributes/AllureStoryAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureStoryAttribute.cs rename to Allure.Xunit/Attributes/AllureStoryAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs b/Allure.Xunit/Attributes/AllureSubSuiteAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureSubSuiteAttribute.cs rename to Allure.Xunit/Attributes/AllureSubSuiteAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureSuiteAttribute.cs b/Allure.Xunit/Attributes/AllureSuiteAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureSuiteAttribute.cs rename to Allure.Xunit/Attributes/AllureSuiteAttribute.cs diff --git a/Allure.XUnit/Attributes/AllureTagAttribute.cs b/Allure.Xunit/Attributes/AllureTagAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/AllureTagAttribute.cs rename to Allure.Xunit/Attributes/AllureTagAttribute.cs diff --git a/Allure.XUnit/Attributes/IAllureInfo.cs b/Allure.Xunit/Attributes/IAllureInfo.cs similarity index 100% rename from Allure.XUnit/Attributes/IAllureInfo.cs rename to Allure.Xunit/Attributes/IAllureInfo.cs diff --git a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs b/Allure.Xunit/Attributes/Steps/AllureAfterAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs rename to Allure.Xunit/Attributes/Steps/AllureAfterAttribute.cs diff --git a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs b/Allure.Xunit/Attributes/Steps/AllureBeforeAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs rename to Allure.Xunit/Attributes/Steps/AllureBeforeAttribute.cs diff --git a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs b/Allure.Xunit/Attributes/Steps/AllureStepAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs rename to Allure.Xunit/Attributes/Steps/AllureStepAttribute.cs diff --git a/Allure.XUnit/Attributes/Steps/NameAttribute.cs b/Allure.Xunit/Attributes/Steps/NameAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/Steps/NameAttribute.cs rename to Allure.Xunit/Attributes/Steps/NameAttribute.cs diff --git a/Allure.XUnit/Attributes/Steps/SkipAttribute.cs b/Allure.Xunit/Attributes/Steps/SkipAttribute.cs similarity index 100% rename from Allure.XUnit/Attributes/Steps/SkipAttribute.cs rename to Allure.Xunit/Attributes/Steps/SkipAttribute.cs diff --git a/Allure.XUnit/ComposedMessageSink.cs b/Allure.Xunit/ComposedMessageSink.cs similarity index 100% rename from Allure.XUnit/ComposedMessageSink.cs rename to Allure.Xunit/ComposedMessageSink.cs diff --git a/Allure.XUnit/README.md b/Allure.Xunit/README.md similarity index 100% rename from Allure.XUnit/README.md rename to Allure.Xunit/README.md diff --git a/Allure.XUnit/Schemas/allureConfig.schema.json b/Allure.Xunit/Schemas/allureConfig.schema.json similarity index 100% rename from Allure.XUnit/Schemas/allureConfig.schema.json rename to Allure.Xunit/Schemas/allureConfig.schema.json diff --git a/Allure.XUnit/TypeExtensions.cs b/Allure.Xunit/TypeExtensions.cs similarity index 100% rename from Allure.XUnit/TypeExtensions.cs rename to Allure.Xunit/TypeExtensions.cs