allure-framework / allure-csharp

Allure integrations for C# test frameworks
https://allurereport.org/
Apache License 2.0
104 stars 64 forks source link

Exception in AllureDisplayIgnoredAttribute if a test with cases marked with [Ignore] #518

Open gamerka opened 3 weeks ago

gamerka commented 3 weeks ago

[//]: # ( . Note: for support questions, please create a discussion at https://github.com/orgs/allure-framework/discussions. . This repository's issues are reserved for feature requests and bug reports. . . Make sure you have a clear name for your issue. The name should start with a capital . letter and no dot is required in the end of the sentence. An example of good issue names: . . - The report is broken in IE11 . - Add an ability to disable default plugins . - Support emoji in test descriptions )

I'm submitting a ...

What is the current behavior?

If test class have test method with test cases with Ignore attribute.

If the current behavior is a bug, please provide the steps to reproduce and, if possible, a minimal demo of the problem

Add test with cases to a test class with AllureDisplayIgnored attribute and mark the whole test method with Ignore attribute. Run this test from IDE or with dotnet test - no results file for this test in allure-results directory. Run debug of test from IDE, set breakpoint inside AllureDisplayIgnoredAttribute class in EmitResultForIgnoredTestInTestPlan method executing by steps you will catch an exception in AllureNUnitHelper.CreateTestResult(test). Sample project: https://github.com/gamerka/allure-nunit-ignore-bug

What is the expected behavior?

Result files for this test appear in allure-results directory.

What is the motivation / use case for changing the behavior?

Currently I have not found any workaround, my ignored tests are just missing from reports.

Please tell us about your environment:

Other information

Exception:

System.InvalidCastException: 'Unable to cast object of type 'NUnit.Framework.Internal.ParameterizedMethodSuite' to type 'NUnit.Framework.Internal.TestFixture'.'
This exception was originally thrown at this call stack:
    Allure.NUnit.Core.AllureNUnitHelper.GetTestFixture(NUnit.Framework.Interfaces.ITest) in AllureNUnitHelper.cs
    Allure.NUnit.Core.AllureNUnitHelper.IterateAllAllureAttribites(NUnit.Framework.Interfaces.ITest) in AllureNUnitHelper.cs
    Allure.NUnit.Core.AllureNUnitHelper.UpdateTestDataFromAllureAttributes(NUnit.Framework.Interfaces.ITest, Allure.Net.Commons.TestResult) in AllureNUnitHelper.cs
    Allure.NUnit.Core.AllureNUnitHelper.CreateTestResult(NUnit.Framework.Interfaces.ITest) in AllureNUnitHelper.cs
    Allure.NUnit.Attributes.AllureDisplayIgnoredAttribute.EmitResultForIgnoredTestInTestPlan(NUnit.Framework.Interfaces.ITest) in AllureDisplayIgnoredAttribute.cs
    Allure.NUnit.Attributes.AllureDisplayIgnoredAttribute.AfterTest(NUnit.Framework.Interfaces.ITest) in AllureDisplayIgnoredAttribute.cs
    NUnit.Framework.Internal.Commands.TestActionItem.AfterTest(NUnit.Framework.Interfaces.ITest) in TestActionItem.cs
    NUnit.Framework.Internal.Commands.AfterTestActionCommand..ctor.AnonymousMethod__0(NUnit.Framework.Internal.TestExecutionContext) in AfterTestActionCommand.cs
    NUnit.Framework.Internal.Commands.AfterTestCommand.Execute(NUnit.Framework.Internal.TestExecutionContext) in AfterTestCommand.cs
    NUnit.Framework.Internal.Commands.AfterTestCommand.Execute.AnonymousMethod__0() in AfterTestCommand.cs
    ...
    [Call Stack Truncated]

[//]: # ( . e.g. detailed explanation, stacktraces, related issues, suggestions . how to fix, links for us to have more context, eg. Stack Overflow, Gitter etc )