[英]@RunWith(CucumberWithSerenity.class) throws NoClassDefFound cucumber/runtime/junit/Assertions
Trying to run Cucumber with Serenity using JUnit 5.尝试使用 JUnit 5 使用 Serenity 运行 Cucumber。
When the Test Runner has a @RunWith(Cucumber.class)
annotation, the tests run, although Serenity does not record the outcome.当测试运行器具有
@RunWith(Cucumber.class)
注释时,测试会运行,但 Serenity 不会记录结果。
When the Test Runner has @RunWith(CucumberWithSerenity.class)
, a "NoClassDefFound cucumber/runtime/junit/Assertions" is thrown.当测试运行器有
@RunWith(CucumberWithSerenity.class)
,会抛出“NoClassDefFounducumber/runtime/junit/Assertions”。
I thought it may be JUnit 5, so I switched to JUnit 4 and the same outcome happens.我认为它可能是 JUnit 5,所以我切换到 JUnit 4 并且发生了相同的结果。
I loaded the sample project into GitHub: https://github.com/WB3Tech/Cucumber-Serenity-JUnit5我将示例项目加载到 GitHub: https : //github.com/WB3Tech/Cucumber-Serenity-JUnit5
The goal is to build the project then be able to see the Cucumber results in the Serenity html output.目标是构建项目然后能够在 Serenity html 输出中看到 Cucumber 结果。
Anyone have an idea of where I may be going wrong?任何人都知道我可能会出错的地方?
See https://github.com/serenity-bdd/serenity-core/#cucumber-4 .请参阅https://github.com/serenity-bdd/serenity-core/#cucumber-4 。 I expect Serenity will only work with JUnit 5 in vintage mode.
我希望 Serenity 只能在老式模式下与 JUnit 5 一起使用。
There were two separate issues:有两个不同的问题:
I was using v4.7.1.我使用的是 v4.7.1。 When I rolled back to 4.2.0 from 4.7.1, the NoClassDefFound error went away.
当我从 4.7.1 回滚到 4.2.0 时,NoClassDefFound 错误消失了。 When I bumped up to 4.2.1, I got a new NoClassDefFound error.
当我升级到 4.2.1 时,出现了一个新的 NoClassDefFound 错误。 I tried all the versions from 4.2.1 to 4.7.1 and got different NoClassDefFound errors.
我尝试了从 4.2.1 到 4.7.1 的所有版本,但遇到了不同的 NoClassDefFound 错误。
When I used v1.0.17, a warning about missing dependencies comes up.当我使用 v1.0.17 时,出现关于缺少依赖项的警告。 When I used v1.0.15, this missing dependencies warning disappears.
当我使用 v1.0.15 时,这个缺少依赖项的警告消失了。
There looks to be bad references to a v2.0.59 of serenity-screenplay and serenity-screenplay-webdriver used by serenity-cucumber4 that do not exist in the maven repo.似乎对 Maven 存储库中不存在的 serenity-cucumber4 使用的 serenity-screenplay 和 serenity-screenplay-webdriver 的 v2.0.59 有不好的引用。
This was another obstacle I ran into that was not discussed in the primary issue这是我遇到的另一个障碍,在主要问题中没有讨论
All is working now现在一切正常
You can read more about how I approached solving the problem at: https://github.com/serenity-bdd/serenity-cucumber4/issues/9您可以在以下位置阅读有关我如何解决问题的更多信息: https : //github.com/serenity-bdd/serenity-cucumber4/issues/9
You can also see the repo here: https://github.com/WB3Tech/Cucumber-Serenity-JUnit5您还可以在此处查看存储库: https : //github.com/WB3Tech/Cucumber-Serenity-JUnit5
I upgrade to Java 12, and half-way implemented JUnit5.我升级到 Java 12,中途实现了 JUnit5。 The TestRunner is not using the @ExtendWith() attribute that replaced @RunWith, it is still using the @RunWith() attribute from the jupiter-vintage package.
TestRunner 没有使用取代@RunWith 的@ExtendWith() 属性,它仍然使用jupiter-vintage 包中的@RunWith() 属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.