简体   繁体   English

@RunWith(CucumberWithSerenity.class) 抛出 NoClassDefFound 黄瓜/runtime/junit/Assertions

[英]@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:有两个不同的问题:

Dependency |依赖 | cucumber-java - > v4.2.0黄瓜-java - > v4.2.0

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 错误。

Dependency |依赖 | serenity-cucumber4 - v1.0.17宁静黄瓜4 - v1.0.17

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这是我遇到的另一个障碍,在主要问题中没有讨论

Solutions解决方案

  • I kept cucumber-java at v4.2.0我将黄瓜 java 保留在 v4.2.0
  • I kept serenity-cucumber4 at v1.0.15我在 v1.0.15 保留了 serenity-cucumber4

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.

相关问题 在 IntelliJ 运行程序中配置 @RunWith 以使用 CucumberWithSerenity.class 而不是 Cucumber.class - Configuring @RunWith to use CucumberWithSerenity.class instead of Cucumber.class in IntelliJ runners @RunWith(Cucumber.class) 错误。 导入 cucumber.api.junit.Cucumber; 无法解决 - @RunWith(Cucumber.class) error. The import cucumber.api.junit.Cucumber; cannot be resolved 相当于 JUnit5 的 @RunWith(JUnitPlatform.class) - Equivalent for @RunWith(JUnitPlatform.class) for JUnit5 黄瓜无法解析为一种类型。 @RunWith(Cucumber.class) - Cucumber cannot be resolved to a type. @RunWith(Cucumber.class) 如何一步一步地运行@RunWith(Cucumber.class) - How to run @RunWith(Cucumber.class) step by step @RunWith(JUnit4.class) + GrpcCleanupRule 与 @RunWith(SpringJUnit4ClassRunner.class) + @Autowired - @RunWith(JUnit4.class) + GrpcCleanupRule vs @RunWith(SpringJUnit4ClassRunner.class) + @Autowired junit @RunWith(Parameterized.class) 注释正在抛出 null - junit @RunWith(Parameterized.class) annotation is throwing null 无法在org.junit.runner中找到/导入Runwith类? - Unable to find/import Runwith Class in org.junit.runner? 如何使用对象使用Runwith注释实例化JUnit类? - How to use an object to instantiate JUnit class with Runwith annotation? 在JUnit中使用@RunWith有解决方法吗? - Is there a workaround for using @RunWith in JUnit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM