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/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 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/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 a5dc19cc..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/Attachments.cs b/Allure.XUnit/Attachments.cs deleted file mode 100644 index 1063dfcd..00000000 --- a/Allure.XUnit/Attachments.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Text; -using Allure.Net.Commons; -using HeyRed.Mime; - -namespace Allure.XUnit -{ - public abstract 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 = "") => - AllureApi.AddAttachment(name, MimeTypesMap.GetMimeType(extension), content, extension); - public static void File(string name, string path) => - AllureApi.AddAttachment(path, name); - public static void File(string fileName) => File(fileName, fileName); - } -} \ 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/Attributes/Steps/AllureAfterAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs deleted file mode 100644 index 241e9193..00000000 --- a/Allure.XUnit/Attributes/Steps/AllureAfterAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -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, AllureXunitHelper.ExceptionTypes) - { - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs deleted file mode 100644 index 9602f1ff..00000000 --- a/Allure.XUnit/Attributes/Steps/AllureBeforeAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -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) - { - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs b/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs deleted file mode 100644 index 0dccb610..00000000 --- a/Allure.XUnit/Attributes/Steps/AllureStepAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -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) - { - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/Attributes/Steps/NameAttribute.cs b/Allure.XUnit/Attributes/Steps/NameAttribute.cs deleted file mode 100644 index 1a266294..00000000 --- a/Allure.XUnit/Attributes/Steps/NameAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Allure.Net.Commons.Steps; - -namespace Allure.XUnit.Attributes.Steps -{ - public class NameAttribute : AbstractNameAttribute - { - public NameAttribute(string name) : base(name) - { - } - } -} \ No newline at end of file diff --git a/Allure.XUnit/Attributes/Steps/SkipAttribute.cs b/Allure.XUnit/Attributes/Steps/SkipAttribute.cs deleted file mode 100644 index f036b944..00000000 --- a/Allure.XUnit/Attributes/Steps/SkipAttribute.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Allure.Net.Commons.Steps; - -namespace Allure.XUnit.Attributes.Steps -{ - public class SkipAttribute : AbstractSkipAttribute - { - } -} \ No newline at end of file diff --git a/Allure.XUnit/README.md b/Allure.XUnit/README.md deleted file mode 100644 index 64a5e79e..00000000 --- a/Allure.XUnit/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# 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 -implements .NET Standard 2.1. - -## Quick start - -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. - -## Further readings - -Learn more from [the documentation for Allure NUnit](https://allurereport.org/docs/nunit/). - -Some examples are available [here](https://github.com/allure-framework/allure-csharp/tree/main/Allure.XUnit.Examples). - -## 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 -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.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`. - -## Known issues and limitations - -### Rosetta is required for users on Mac with Apple silicon -If you're developing on a Mac machine with Apple silicon, make sure you have -Rosetta installed. Follow this article for the instructions: -https://support.apple.com/en-us/HT211861 - -You may also install Rosetta via the CLI: - -```shell -/usr/sbin/softwareupdate --install-rosetta --agree-to-license -``` - -### MonoMod.Core issues - -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. - -Those features are unavailable on ARM64 due to limitations of MonoMod.Core. -Additionally, they might not work in some other rare circumstances. - -Issue [#369] contains some additional details. - -[#369]: https://github.com/allure-framework/allure-csharp/issues/369 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 diff --git a/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj b/Allure.Xunit.Examples/Allure.Xunit.Examples.csproj similarity index 83% rename from Allure.XUnit.Examples/Allure.XUnit.Examples.csproj rename to Allure.Xunit.Examples/Allure.Xunit.Examples.csproj index e26b6f4a..79911b5b 100644 --- a/Allure.XUnit.Examples/Allure.XUnit.Examples.csproj +++ b/Allure.Xunit.Examples/Allure.Xunit.Examples.csproj @@ -20,8 +20,7 @@ - - + diff --git a/Allure.XUnit.Examples/ExampleParameterisedTests.cs b/Allure.Xunit.Examples/ExampleParameterisedTests.cs similarity index 97% rename from Allure.XUnit.Examples/ExampleParameterisedTests.cs rename to 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 similarity index 96% rename from Allure.XUnit.Examples/ExampleStepAttributes.cs rename to 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 similarity index 98% rename from Allure.XUnit.Examples/ExampleUnitTests.cs rename to 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 similarity index 66% rename from Allure.XUnit.Examples/TestData/MyTestClass.cs rename to 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 similarity index 92% rename from Allure.XUnit.Examples/TestData/TestClassData.cs rename to 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 similarity index 97% rename from Allure.XUnit.Examples/TestData/TestDataGenerators.cs rename to 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.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 70% rename from Allure.XUnit/Allure.XUnit.csproj rename to Allure.Xunit/Allure.Xunit.csproj index e9318cd4..9af2ec8d 100644 --- a/Allure.XUnit/Allure.XUnit.csproj +++ b/Allure.Xunit/Allure.Xunit.csproj @@ -1,9 +1,9 @@  - netcoreapp2.0;netstandard2.1;net5.0;net6.0 + Allure.Xunit.reporters + netstandard2.0;netcoreapp3.1 true - Allure.XUnit Shumakov Ivan Create beautiful reports from your xUnit.net tests. Allure-X-Color.png @@ -31,11 +31,4 @@ - - - - - - - diff --git a/Allure.XUnit/AllureMessageSink.cs b/Allure.Xunit/AllureMessageSink.cs similarity index 90% rename from Allure.XUnit/AllureMessageSink.cs rename to Allure.Xunit/AllureMessageSink.cs index f84050ab..a62332cb 100644 --- a/Allure.XUnit/AllureMessageSink.cs +++ b/Allure.Xunit/AllureMessageSink.cs @@ -4,15 +4,15 @@ 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 : + class AllureMessageSink : DefaultRunnerReporterWithTypesMessageHandler { static AllureTestPlan TestPlan @@ -49,6 +49,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) @@ -156,7 +161,7 @@ void OnTestFinished(MessageHandlerArgs args) }); } - this.allureTestData.Remove(test, out _); + this.allureTestData.TryRemove(test, out _); } AllureXunitTestData GetOrCreateTestData(ITest test) @@ -178,7 +183,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 { @@ -207,8 +215,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); } @@ -216,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.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..06ae2956 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.XUnit/AllureXunitConfiguration.cs b/Allure.Xunit/AllureXunitConfiguration.cs similarity index 97% rename from Allure.XUnit/AllureXunitConfiguration.cs rename to 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 similarity index 88% rename from Allure.XUnit/AllureXunitFacade.cs rename to Allure.Xunit/AllureXunitFacade.cs index 2e1793cb..2c82bdb0 100644 --- a/Allure.XUnit/AllureXunitFacade.cs +++ b/Allure.Xunit/AllureXunitFacade.cs @@ -1,17 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; +using System.Text.RegularExpressions; using Xunit; using Xunit.Abstractions; #nullable enable -namespace Allure.XUnit +namespace Allure.Xunit { - public static class AllureXunitFacade + static class AllureXunitFacade { - public static IMessageSink CreateAllureXunitMessageHandler( + 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 ) diff --git a/Allure.XUnit/AllureXunitHelper.cs b/Allure.Xunit/AllureXunitHelper.cs similarity index 71% rename from Allure.XUnit/AllureXunitHelper.cs rename to Allure.Xunit/AllureXunitHelper.cs index 5bf99b3f..1f7fc7b1 100644 --- a/Allure.XUnit/AllureXunitHelper.cs +++ b/Allure.Xunit/AllureXunitHelper.cs @@ -1,57 +1,20 @@ -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 Xunit; using Xunit.Abstractions; -using Xunit.Sdk; #nullable enable namespace Allure.Xunit { - public static class AllureXunitHelper + static class AllureXunitHelper { - internal interface ITestResultAccessor - { - TestResultContainer TestResultContainer { get; set; } - TestResult TestResult { get; set; } - } - - internal static List ExceptionTypes = new() - { - typeof(XunitException) - }; - - 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 const string NS_OBSOLETE_MSG = + "The Allure.XUnit namespace is deprecated. Please, use Allure.Xunit instead"; internal static TestResultContainer StartNewAllureContainer( string className @@ -72,8 +35,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; @@ -184,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