[英]tell cucumber how to use camelCase
我在測試自動化中使用 Maven 和黃瓜。 我如何在編寫代碼時使用camelCase,因為Cucumber 默認使用snakeCase。 有沒有辦法在 maven 的 pom.xml 文件中管理它?
順便說一句,我的 IDE 是 VS Code。
Tnx
如果您使用的是@CucumberOptions
cucumber-junit
您可以將@CucumberOptions
添加到您的 JUnit4 runner 類中。
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
import static io.cucumber.junit.CucumberOptions.SnippetType.CAMELCASE;
@RunWith(Cucumber.class)
@CucumberOptions(snippets = CAMELCASE)
public class RunCucumberTest {
}
您還可以在包含以下內容的src/test/resources
創建cucumber.properties
文件:
cucumber.snippet-type=camelcase
如果您使用的是junit-platform.properties
cucumber-junit-platform-engine
這個文件應該是名稱junit-platform.properties
。
步驟定義使用蛇形而不是駱駝形。 我們只需要告訴 Cucumber 這就是我們想要的:
java -cp“jars/*”cucumber.api.cli.Main -p漂亮--snippets駝峰特征
現在,當我們運行 ./cucumber 時,它會生成具有符合 Java 標准的方法名稱的片段
來自 The Cucumber for Java 一書
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.