@RunWith(CucumberWithSerenity.class)抛出NoClassDefFound黄瓜/运行时/ junit / Assertions

时间:2019-07-30 19:45:26

标签: java junit cucumber serenity-bdd cucumber-serenity

尝试使用JUnit 5以Serenity运行Cucumber。

当测试运行程序具有@RunWith(Cucumber.class)批注时,尽管Serenity不会记录结果,但运行测试。

当测试运行程序具有@RunWith(CucumberWithSerenity.class)时,将引发“ NoClassDefFound黄瓜/运行时/ junit / Assertions”。

我以为可能是JUnit 5,所以我切换到JUnit 4,结果还是一样。

我将示例项目加载到GitHub:https://github.com/WB3Tech/Cucumber-Serenity-JUnit5

目标是构建项目,然后能够在Serenity html输出中查看Cucumber结果。

有人知道我可能要去哪里了吗?

2 个答案:

答案 0 :(得分:1)

请参见https://github.com/serenity-bdd/serenity-core/#cucumber-4。我希望Serenity仅能在老式模式下使用JUnit 5。

答案 1 :(得分:0)

有两个独立的问题:

依赖关系|黄瓜Java-> v4.2.0

我正在使用v4.7.1。当我从4.7.1回滚到4.2.0时,NoClassDefFound错误消失了。 当我提高到4.2.1时,出现了一个新的NoClassDefFound错误。我尝试了从4.2.1到4.7.1的所有版本,并遇到了不同的NoClassDefFound错误。

依赖关系| serenity-cucumber4-v1.0.17

当我使用v1.0.17时,会出现有关缺少依赖项的警告。 当我使用v1.0.15时,此丢失的依赖项警告消失了。

似乎对Serenity-cucumber4所使用的serenity-screenplay和serenity-screenplay-webdriver v2.0.59的引用不正确,

这是我遇到的另一个障碍,主要问题中没有讨论

解决方案

  • 我将Cucumber-java保留在v4.2.0中
  • 我将serenity-cucumber4保持在v1.0.15

现在一切正常

您可以在https://github.com/serenity-bdd/serenity-cucumber4/issues/9

了解更多有关我如何解决问题的信息。

您还可以在此处查看该存储库:https://github.com/WB3Tech/Cucumber-Serenity-JUnit5

我升级到Java 12,并中途实现了JUnit5。 TestRunner没有使用取代@RunWith的@ExtendWith()属性,而是仍然使用jupiter-vintage软件包中的@RunWith()属性。