Search code examples
c#asp.net-coreattributesnunitallure

AllureFeature duplicates over multiple NUnit test cases


I'd like to use the AllureFeature attribute accross different test cases, however in the report, each feature has all the tests from the testcases

In the below example we have tests related to testing tax rules. We apply tax rules to shipping methods, directly to products and to surcharges. I'd like the report to show a breakdown of all shipping method related tests as well as tax rules etc.

namespace Tests.Ecommerce
{
    [TestFixture]
    [AllureNUnit]
    [AllureEpic("Ecommerce")]
    [AllureFeature("TaxRule")]
    public class TaxRules : EcommerceBase
    {
        [TestCase("ProductVariant")]
        [TestCase("Shipping"), AllureFeature("Shipping")]
        [TestCase("Surcharge"), AllureFeature("Surcharge")]
        public static void MyRandomTest(string feature)
        {
             // Do stuff
        }
     }
}

Solution

  • After some further research. It doesn't look like it's possible to pass in alternate attributes in test cases.

            [TestCase("ProductVariant")]
            [TestCase("Shipping"), AllureFeature("Shipping")]
            [TestCase("Surcharge"), AllureFeature("Surcharge")]
            public static void MyRandomTest(string feature)
            {
                 // Do stuff
            }
    

    This should rather be:

            [TestCase("ProductVariant")]
            [TestCase("Shipping")]
            [TestCase("Surcharge")]
            [AllureFeature("Surcharge")]
            public static void MyRandomTest(string feature)
            {
                 // Do stuff
            }
    

    Which, unfortunately, doesn't give me the desired outcome. The solution is to add AllureFeature programatically using:

    AllureLifecycle.Instance.UpdateTestCase(x => x.labels.Add(Label.Feature(arg)));