BDD Cucumber+testng 集成

Moon · 2019年05月15日 · 最后由 Bensir 回复于 2019年05月15日 · 3117 次阅读

maven 依赖

1、cucumber 依赖

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-spring</artifactId>
    <version>1.2.4</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.4</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>1.2.4</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.4</version>
</dependency>
<dependency>

2、testng 依赖

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.11</version>
</dependency>

3、cucumber-testng 依赖

<dependency>
 <groupId> info.cukes</groupId>
 <artifactId> cucumber-testng</artifactId>
 <version> 1.2.4</version>
</dependency>

Runner

package com.test.zfj.qa;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.testng.TestNGCucumberRunner;


@CucumberOptions(
        features ={"src/test/resources/Feature/testController.feature"},
        plugin={"pretty", "html:target/cucumber", "json:target/cucumber/cucumber.json", "junit:target/junit"})
public class RunnerName extends AbstractTestNGCucumberTests {
    private TestNGCucumberRunner testNGCucumberRunner;
}

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite" parallel="tests" thread-count="9">
    <test name="随便自己取个名字" >
        <classes>
            <class name="com.test.zfj.qa.RunnerName"></class>
        </classes>
    </test>
</suite>

feature 及 steps 按 cucumber 格式

共收到 1 条回复 时间 点赞
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册