【问题标题】:How to convert Specflow test results to Cucumber Messages format如何将 Specflow 测试结果转换为 Cucumber Messages 格式
【发布时间】:2021-05-07 10:43:52
【问题描述】:

我的目标是推动 Specflow test results to CucumberStudio。格式应该是Cucumber Messages,但是当像这样从命令行运行 Specflow 测试时,我无法获得那种“记录器”格式。

dotnet test -r C:\Dev\ws\ProjectName\TestResults

我尝试使用 NuGet 安装 JunitXml.TestLogger,以获取该格式,希望随后可以将其转换为 Cucumber 消息。

dotnet test -r C:\Dev\ws\ProjectName\TestResults --logger:junit

然后我尝试使用@cucumber/json-to-messages进行转换。

npm install -g @cucumber/json-to-messages

但我无法成功运行自述文件中概述的命令。

从 PowerShell 运行

cat .\TestResults\TestResults.xml | C:\Users\Admin\AppData\Roaming\npm\node_modules\@cucumber\json-to-messages\bin\json-to-messages > my_report.messages

我遇到了一个错误

Cannot run a document in the middle of a pipeline: 
C:\Users\Admin\AppData\Roaming\npm\node_modules\@cucumber\json-to-messages\bin\json-to-messages.
+ ... sults.xml | C:\Users\Admin\AppData\Roaming\npm\node_modules\@cucumber ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (C:\Users\Admin\...son-to-messages:String) [], RuntimeException
+ FullyQualifiedErrorId : CantActivateDocumentInPipeline

这些工具是存在的,但我显然很难正确使用它们。任何帮助表示赞赏。

【问题讨论】:

  • 您能详细说明您使用的是哪个 Cucumber 版本吗?
  • 我正在使用 SpecFlow v3.6.23(Cucumber 的 .NET 风格)

标签: npm cucumber specflow


【解决方案1】:

我认为您应该导出为 JSON,而不是 JUnit,转换器才能正常工作。我有一段时间没有玩 SpecFlow,但我认为 SpecNuts (https://github.com/DonutReport/SpecNuts) 会生成一个 JSON 文件,@cucumber/json-to-messages 可以使用。

【讨论】:

    【解决方案2】:

    我一直在研究这个,针对 .Net 5.0 的 Specflow 项目。不幸的是,据我所知,SpecNuts 已经 4 年没有更新了,将它迁移到 .Net 5.0 是一项艰巨的任务(目前 SpecNuts 似乎针对 .Net 框架 4.6)。

    【讨论】:

      猜你喜欢
      • 2019-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多