1. junit  配置
@RunWith(Cucumber.class)
@CucumberOptions(format ={"pretty","html:target/cucumber"},
features={"src/main/java/demoapp"},tags={"@third"})
public class test { }
# language: zh-CN
功能:测试
@third
场景大纲:一些测试
假如 firstw "demo"
当 demoinfo <name>
那么 appdemo <info>
例子:
|name| info|
|first|dalong|
|second|aaaaa|
Feature:Belly
@first
ScenarioOutline: a few cukes
Given firstw "demo"
When demoinfo <name>
Then appdemo <info>
Examples:
|name| info|
|first|dalong|
|second|aaaaa|
publicclassMyStepdefs{
@Given("I have (\\d+) cukes in my belly")
publicvoid I_have_cukes_in_my_belly(int cukes){
System.out.format("Cukes: %n\n", cukes);
}
@When("^I wait (\\d+) hour$")
publicvoid i_wait_hour(int arg1)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
thrownewPendingException();
}
@Then("^dodemo$")
publicvoid dodemo()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("dodemo");
}
@Given("^first \"([^\"]*)\"$")
publicvoid first(String arg1)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("first"+": "+ arg1);
}
@Then("^my belly should growl$")
publicvoid my_belly_should_growl()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
thrownewPendingException();
}
@Given("^first demo$")
publicvoid first_demo()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("first_demo");
}
@When("^user names$")
publicvoid user_names(DataTable arg1)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
List<List<String>>list= arg1.raw();
System.out.println(list.get(0));
System.out.println(arg1.toString());
}
@When("^demoinfo ([^\"]*)$")
publicvoid demoinfo_name(String name)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println(name+"demoinfo_name");
//Assert.assertTrue(false);
}
@Then("^appdemo ([^\"]*)$")
publicvoid appdemo_info(String name )throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println(name+"appdemo_info");
}
@When("^call me$")
publicvoid call_me()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("call me");
}
@Then("^docall$")
publicvoid docall()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("docall");
}
@Given("^firstw \"([^\"]*)\"$")
publicvoid firstw(String arg1)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("firstw");
}
@When("^demoinfo$")
publicvoid demoinfo()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("demoinfo");
}
@When("^printinfos$")
publicvoid printinfos(List<String> info)throwsThrowable{
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
info.forEach(newConsumer<String>(){
@Override
publicvoid accept(String t){
// TODO Auto-generated method stub
System.out.println(t+"demo info");
}
});
}
@Then("^appdemo$")
publicvoid appdemo()throwsThrowable{
// Write code here that turns the phrase above into concrete actions
System.out.println("appdemo");
}
}
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

  

Cucumber 使用例子的更多相关文章

  1. (转载)中文Appium API 文档

    该文档是Testerhome官方翻译的源地址:https://github.com/appium/appium/tree/master/docs/cn官方网站上的:http://appium.io/s ...

  2. 中文Appium API 文档

    该文档是Testerhome官方翻译的源地址:https://github.com/appium/appium/tree/master/docs/cn官方网站上的:http://appium.io/s ...

  3. Cucumber语法及测试用例<一>

    工作原因,最近一直在研究cucumber的 语法以及它和java之间的关系.鉴于是初学者且代码基础薄弱,我开始摸索前行,感谢分享博客且也在一路前行的人儿们. 1.基本语法为:此处举例两种区别一看即知- ...

  4. Cucumber命令行接口

    1. cucumber的命令行选项 首先查看命令行选项.和其它命令行工具一样,cucumber提供了—help选项.下面是cucumber帮助的一个缩减版本: $ cucumber --help -r ...

  5. uiautomator+cucumber实现自动化测试

    前提 由于公司业务要求,所以自动化测试要达到以下几点: 跨应用的测试 测试用例可读性强 测试报告可读性强 对失败的用例有截图保存并在报告中体现 基于以上几点,在对自动化测试框架选型的时候就选择了uia ...

  6. Cucumber 行为驱动开发简介

    Cucumber 是一个能够理解用普通语言 描述的测试用例的支持行为驱动开发(BDD)的自动化测试工具,用Ruby编写,支持Java和.Net等多种开发语言. 现在看看Cucumber中用到的术语 . ...

  7. 行为驱动:Cucumber + Selenium + Java(四) - 实现测试用例的参数化

    在上一篇中,我们介绍了Selenium + Cucumber + Java框架下的使用Tags对测试用例分组的实现方法,这一篇我们用数据表格来实现测试用例参数化. 4.1 什么是用例参数化 实际测试中 ...

  8. 【Cucumber】【命令行】

    知识点 参考:https://www.cnblogs.com/worklog/p/5253297.html cucumber的命令行选项 首先查看命令行选项.和其它命令行工具一样,cucumber提供 ...

  9. cucumber java从入门到精通(4)Scenario Outline及数据驱动

    cucumber java从入门到精通(4)Scenario Outline及数据驱动 到目前为止,我们的TodoList类工作良好,不过离我们的预期--任务清单系统还是有不少差距,究其原因不过如下: ...

随机推荐

  1. pahlcon:cookies设置

    非加密方式(简单,但不推荐) 步骤 1 在全局容器中加入Cookie: $di->set('cookies', function () { $cookies = new \Phalcon\Htt ...

  2. 微信小程序UI------实现携程首页顶部的界面(弹性布局)

    今天写了一个携程界面的UI,利用H5的弹性盒子来实现,学过H5弹性盒子的,来看是比较方便的,因为CSS代码都差不多. 可以看看这篇博客 快速使用CSS 弹性盒子 效果图如下: 主要是携程首页的四个模块 ...

  3. mui 禁止透明背景点击关闭弹窗遮罩

    //禁止关闭遮罩 window.addEventListener('tap', function(e) { e.target.className == 'mui-backdrop mui-active ...

  4. eclipse使用lombok

    1.下载lombok.jar,将lombok复制到eclipse的安装路径下,如图: 2.在eclipse.ini配置文件最后加入:-javaagent:D:\Program Files\Eclips ...

  5. bzoj3673可持久化并查集

    n个集合 m个操作操作:1 a b 合并a,b所在集合2 k 回到第k次操作之后的状态(查询算作操作)3 a b 询问a,b是否属于同一集合,是则输出1否则输出0 0<n,m<=2*10^ ...

  6. node-glob 匹配通配符

    1.https://www.cnblogs.com/liulangmao/p/4552339.html 2.https://github.com/isaacs/node-glob 3.https:// ...

  7. python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'

    python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...

  8. php5.4.0以后加入trait实现代码复用【摘录】

    在http://www.php.net/manual/zh/language.oop5.traits.php 查看了一下5.4.0提供的特性trait顺便做一个标记(总结): 首先要明确trait和类 ...

  9. js函数的伪重载

    这也是今天写东西是遇到的一个问题,导致我联想起了函数重载的问题. 在javascript中是没有函数重载机制的,对于用惯了java开发的同学可能就表示吃惊了,我屮艸芔茻,函数 没有重载?那怎么搞?!! ...

  10. EventUtil对象

    var EventUtil = { addHandler : function(element,type,handler){ if(element.addEventListener){ element ...