带有SpecFlow钩子的NuGet软件包

问题描述 投票:0回答:2

我创建了一个SpecFlow挂钩类,以在BDD Specflow C#项目中生成范围报告。它工作正常,并且生成了报告。

[BeforeTestRun]
public static void InitializeReport()
        {
            //Initialize Extent report before test starts
            var htmlReporter = new ExtentHtmlReporter(reportPath);
            htmlReporter.Config.Theme = Theme.Dark;

            //Attach report to reporter
            extent = new AventStack.ExtentReports.ExtentReports();
            extent.AttachReporter(htmlReporter);
        }

[AfterTestRun]
public static AfterTests()
        {
            //Flush report once test completes
            extent.Flush();
        }

要重复使用,我将其作为NuGet库并导入了另一个项目。但是报告没有生成。我们需要为钩子类创建对象来调用它吗?在这种情况下,任何人都可以建议如何触发SpecFlow挂钩。

c# bdd specflow extentreports
2个回答
0
投票

请确保已在类声明上方添加了[Binding]属性,并且没有多个[BeforeTestRun]或[AfterTestRun]属性。

使用多个[BeforeTestRun][AfterTestRun]应该可以,但不确定您的情况。


0
投票

我昨天有这个问题。您需要将Specflow更新到最新版本Specflow 3.0.x仍然存在[AfterTestRun]挂钩未执行(已有多年)的错误。

© www.soinside.com 2019 - 2024. All rights reserved.