BDD Cucumber+testng 集成

Moon · May 15, 2019 · Last by Bensir replied at May 15, 2019 · 235 hits

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 条回复 时间 点赞

入门

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up