You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Selenium+TestNG+Maven+Jenkins框架,Cucumber所需Maven依赖有哪些?

Hey there! Let's walk through exactly what Maven dependencies you need to integrate Cucumber with your TestNG-based automation framework, plus some key setup details to tie everything together.

Required Maven Dependencies

Add these to your pom.xml file. I’ve used recent stable versions (7.14.0) below—just make sure all Cucumber dependencies share the same version to avoid compatibility headaches:

<!-- Core Cucumber functionality -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>7.14.0</version>
    <scope>test</scope>
</dependency>

<!-- Bridge between Cucumber and TestNG (critical for running scenarios as TestNG tests) -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>7.14.0</version>
    <scope>test</scope>
</dependency>

<!-- For writing step definitions in Java (works seamlessly with your existing Selenium code) -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>7.14.0</version>
    <scope>test</scope>
</dependency>

<!-- Optional: For generating human-readable HTML reports -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-html-reporter</artifactId>
    <version>7.14.0</version>
    <scope>test</scope>
</dependency>
Key Setup Tips
  1. Version Compatibility: Ensure your existing TestNG version is 7.0 or newer (Cucumber 7.x+ requires this). Double-check that no conflicting versions are pulled in via Maven—use mvn dependency:tree to verify if needed.
  2. TestNG Runner Class: You’ll need a runner class to trigger Cucumber scenarios through TestNG. Here’s a minimal example:
    import io.cucumber.testng.AbstractTestNGCucumberTests;
    import io.cucumber.testng.CucumberOptions;
    
    @CucumberOptions(
        features = "src/test/resources/features", // Path to your .feature files
        glue = "com.yourteam.stepdefinitions", // Package containing your step definitions
        plugin = {"pretty", "html:target/cucumber-reports.html"} // Report formats
    )
    public class CucumberTestRunner extends AbstractTestNGCucumberTests {
    }
    
  3. Selenium Integration: Since you already have Selenium set up, you can directly use your page objects, drivers, and utility classes inside your Cucumber step definitions—no extra dependencies required here.
  4. Jenkins Integration: Use the standard mvn test command in your Jenkins job to run the tests. For better visibility, install the Jenkins Cucumber Reports plugin to display detailed scenario results directly in the Jenkins dashboard.

内容的提问来源于stack exchange,提问作者Madhavan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:31:07