Cucumber
Cucumber是一个 BDD 行为驱动开发的自动化测试工具
可以用自然的语言进行描述
Cucumber包括Features, Step_definitions, Cucumber command.
1. Features
.feature文件
Feature: 对应test suite
Scenario: test case
Given a website with existing user 对应setup 测试环境
When specfy username, password 对应test 出发被测试件
And click login button
Then user can login 对应assert 断言,验证结果
2. step_definitions
.java文件
根据feature文件中的step编写对应的的测试代码
ConsumerPage.java里已定义了顾客页面的各种元素以及执行的方法
@FindBy(css="button[type='submit']")
ConsumerPage consumerpage;
consumerpage.getUsername().sendKeys('123');
consumerpage.getPwd().sendKeys('123');
consumerpage.clickLoginBtn().click();
if (msg.equals("Sucess")){
}
3. Cucumber command
运行.*feature文件,分析feature中的step运行step_definition中的代码。运行结果会保存为html, fail的情况可查看log.