![](/img/trans.png)
[英]@RunWith(CucumberWithSerenity.class) throws NoClassDefFound cucumber/runtime/junit/Assertions
[英]Configuring @RunWith to use CucumberWithSerenity.class instead of Cucumber.class in IntelliJ runners
我有一個 gradle + Serenity + RestAssured 自動檢查套件設置,我通常在 shell 會話中通過 gradle 命令運行它,但有時我需要使用 IntelliJ 運行單個場景。
當我在 IntelliJ 上運行 Scenarios 時,我通常會收到很多這樣的警告:
8312 [main] WARN cucumber.runtime.SerenityBackend - It looks like you are
running a feature using @RunWith(Cucumber.class)
instead of @RunWith(CucumberWithSerenity.class).
Are you sure this is what you meant to do?
我想知道我可以在哪里以及如何在 IntelliJ 中配置運行/調試配置,以便使用CucumberWithSerenity.class
運行檢查並修復警告。
我正在使用以下依賴項:
serenity-rest-assured:1.9.31
serenity-core:1.9.31
serenity-cucumber:1.9.12
IntelliJ 2018.1.5版(社區版)
下面是 John Ferguson Smart 博客的步驟,他是 Serenity-BDD 的作者(考慮到您已經安裝了Cucumber for Java插件)。
直接從 IntelliJ 使用 Serenity 功能文件運行 Cucumber :
IntelliJ 為 Cucumber 特征文件提供了出色的集成支持。 您甚至可以通過右鍵單擊功能文件來運行功能。 但是當您將 Cucumber 與 Serenity 一起使用時,這將不起作用,因為 Serenity 需要在執行之前檢測特征文件。 幸運的是,這很容易解決。 就是這樣:
- 單擊要運行的功能文件
- 在運行菜單中選擇運行...
- 在上下文菜單中,選擇該功能,然后“編輯...”
- 您現在應該會看到“編輯配置設置”窗口。 將主類設置為“net.serenitybdd.cucumber.cli.Main”
- 將 Glue 字段更改為項目(或步驟定義)的根包
- 點擊應用
現在您可以通過右鍵單擊功能文件直接運行您的功能。
PS 並非所有版本的 Cucumber for Java 插件都能正常工作,尤其是當您剛剛將 IntelliJ IDEA 更新到最新版本時。 我可以確認下一個設置工作正常:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.