![](/img/trans.png)
[英]Configuring @RunWith to use CucumberWithSerenity.class instead of Cucumber.class in IntelliJ runners
[英]@RunWith(CucumberWithSerenity.class) throws NoClassDefFound cucumber/runtime/junit/Assertions
嘗試使用 JUnit 5 使用 Serenity 運行 Cucumber。
當測試運行器具有@RunWith(Cucumber.class)
注釋時,測試會運行,但 Serenity 不會記錄結果。
當測試運行器有@RunWith(CucumberWithSerenity.class)
,會拋出“NoClassDefFounducumber/runtime/junit/Assertions”。
我認為它可能是 JUnit 5,所以我切換到 JUnit 4 並且發生了相同的結果。
我將示例項目加載到 GitHub: https : //github.com/WB3Tech/Cucumber-Serenity-JUnit5
目標是構建項目然后能夠在 Serenity html 輸出中看到 Cucumber 結果。
任何人都知道我可能會出錯的地方?
請參閱https://github.com/serenity-bdd/serenity-core/#cucumber-4 。 我希望 Serenity 只能在老式模式下與 JUnit 5 一起使用。
有兩個不同的問題:
我使用的是 v4.7.1。 當我從 4.7.1 回滾到 4.2.0 時,NoClassDefFound 錯誤消失了。 當我升級到 4.2.1 時,出現了一個新的 NoClassDefFound 錯誤。 我嘗試了從 4.2.1 到 4.7.1 的所有版本,但遇到了不同的 NoClassDefFound 錯誤。
當我使用 v1.0.17 時,出現關於缺少依賴項的警告。 當我使用 v1.0.15 時,這個缺少依賴項的警告消失了。
似乎對 Maven 存儲庫中不存在的 serenity-cucumber4 使用的 serenity-screenplay 和 serenity-screenplay-webdriver 的 v2.0.59 有不好的引用。
這是我遇到的另一個障礙,在主要問題中沒有討論
現在一切正常
您可以在以下位置閱讀有關我如何解決問題的更多信息: 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() 屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.