首页 > 解决方案 > 带有 SpecFlow 挂钩的 NuGet 包

问题描述

我创建了一个 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 库并导入另一个项目。但是报告没有生成。我们是否需要为 hooks 类创建对象来调用它?谁能建议在这种情况下如何触发 SpecFlow 钩子。

标签: c#bddspecflowextentreports

解决方案


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


推荐阅读