- Cucumber - Ruby Testing
- Cucumber - Java Testing
- Cucumber - Debugging
- Cucumber - Reports
- Cucumber - JUnit Runner
- Cucumber - Command Line Options
- Cucumber - Hooks
- Cucumber - Comments
- Cucumber - Data Tables
- Cucumber - Tags
- Cucumber - Scenario Outline
- Cucumber - Annotations
- Cucumber - Scenarios
- Cucumber - Features
- Cucumber - Gherkins
- Cucumber - Environment
- Cucumber - Overview
- Cucumber - Home
Cucumber Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Cucumber - Annotations
它描述了有待执行的试验的前提条件。
例——GIVEN 我是“Facebook”用户
它确定了任何试验情景执行的触发点。
例——WHEN I 进入“设计、用户名和”
之后,检验结果有望完成。
例如,Nlogin应当取得成功。
它提供了两个声明之间的逻辑和条件。 并且可以结合《全球环境倡议》、世界人类环境网和《国家宣言》加以使用。
例: 我进入我的“设计、用户名和大体”;我进入我的“设计、密码和大体”;
它表示任何两份声明之间的逻辑性关系。 也可结合全球环境倡议、世界人类环境网和世界气候论坛的发言加以使用。
例如,Nlogin应当取得成功。 不应丢失BOT主页。
在关键词“设想:”之后,需要掌握试验情景的细节。
例:
设想:
GIVEN 我是“Facebook”用户
WHEN 我现在发言。
目 录 我现在发言。
国家标志应当取得成功。
不应丢失BOT主页。
Scenario Outpne-(待定)
Background
一般来说,在每种假设情景发生之前,就应如何确定。 然而,它是在“Before” hook(稍后将涵盖)之后被处决的。 因此,在我们想要建立网络浏览器或希望建立数据库连接时,最好用于编码。
例:
背景:
Go tobook home page.
Example Scenario
为了更好地了解说明,让情况自动化。
创立一个名为《年度报告》的“夜晚测试项目”。
Go to file ——New —— Others —— Maven —— Maven Project —— Next。
供应集团 Id(Id组将确定你在所有项目中独一无二的项目)。
提供艺术作品 Id. 行为 斜体是 without的名称,没有版本。 你们可以选择下调的任何名字。
Cpck on Finish.
开放pom.xml -
前往Ecppse左手边进行包装。
扩大项目说明。
Locate pom.xml file.
Right-cpck and selected the programme, Open with “Text Editor”.
添加对 Sel的依赖—— 这将表明Maven,将把Selenium jar档案从中央存放处下载到当地存放处。
开放式的om子是ed的,在项目标的内形成依赖物(配对;依赖物和gt;及/依赖物和gt)。
在附属企业主中,产生依赖物(配对;依赖;加固;加固;/ 依附和);
在依赖方提供以下信息。
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.47.1</version> </dependency>
Add Depend for Cucumber-Java - 这将表明Maven,Cucumber文档将从中央存放处下载到当地存放处。
创建另一个依赖方。
在依赖方内部提供以下信息。
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.0.2</version> <scope>test</scope> </dependency>
Add Depend for Cucumber-JUnit - 这将表明Maven,Cucumber Junnit的档案将从中央存放处下载到当地存放处。
创建另一个依赖方。
在依赖方提供以下信息。
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.0.2</version> <scope>test</scope> </dependency>
日尼特附属公司 这将表明Maven, 而Junnit案卷将从中央存放处下载到当地存放处。
创建另一个依赖方。
在依赖方提供以下信息。
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency>
更正。
页: 1
Go to Project - Clean - 发言几分钟。
在src/test/java下建立一个名为“说明”的一揽子方案。
选择新设立的项目。
Right-cpck and selected "New'.
选择“Package”
名称为“Annotation'。
除此以外。
创建名为通知.feature的特辑。
在一揽子大纲中选择和右翼。
Cpck on "New' file.
如outpne.feature。
在档案中撰写以下案文,并予以保存。
Feature: annotation #This is how background can be used to epminate duppcate steps 背景: User navigates to Facebook Given I am on Facebook login page #Scenario with AND 设想: When I enter username as "TOM" And I enter password as "JERRY" Then Login should fail #Scenario with BUT 设想: When I enter username as "TOM" And I enter password as "JERRY" Then Login should fail But Relogin option should be available
编制一个步骤定义文件。
在一揽子大纲中选择和右翼。
Cpck on "New' file.
将档案名称改为annotation.java
在档案中撰写以下案文,并予以保存。
package Annotation; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import cucumber.annotation.en.Given; import cucumber.annotation.en.Then; import cucumber.annotation.en.When; pubpc class annotation { WebDriver driver = null; @Given("^I am on Facebook login page$") pubpc void goToFacebook() { driver = new FirefoxDriver(); driver.navigate().to("https://www.facebook.com/"); } @When("^I enter username as "(.*)"$") pubpc void enterUsername(String arg1) { driver.findElement(By.id("email")).sendKeys(arg1); } @When ("^I enter password as "(.*)"$") pubpc void enterPassword(String arg1) { driver.findElement(By.id("pass")).sendKeys(arg1); driver.findElement(By.id("u_0_v")).cpck(); } @Then("^Login should fail$") pubpc void checkFail() { if(driver.getCurrentUrl().equalsIgnoreCase( "https://www.facebook.com/login.php?login_attempt=1&lwv=110")){ System.out.println("Test1 Pass"); } else { System.out.println("Test1 Failed"); } driver.close(); } @Then("^Relogin option should be available$") pubpc void checkRelogin() { if(driver.getCurrentUrl().equalsIgnoreCase( "https://www.facebook.com/login.php?login_attempt=1&lwv=110")){ System.out.println("Test2 Pass"); } else { System.out.println("Test2 Failed"); } driver.close(); } }
• 创建经营人班级档案。
在一揽子大纲中选择和右翼。
Cpck on "New' file.
如.java
在档案中撰写以下案文,并予以保存。
package Annotation; import org.junit.runner.RunWith; import cucumber.junit.Cucumber; @RunWith(Cucumber.class) @Cucumber.Options(format = {"pretty", "html:target/cucumber"}) pubpc class runTest { }
利用备选办法进行试验——
一揽子勘探者的选择性操作文件。
右翼和选用Omun as'
选择JUSG测试。
在你管理这一类档案时,你将观察下列情况:
Facebook在新的网上浏览器中开放。
将通过电离层对用户名领域的投入。
审校将作为对密码领域的投入通过。
将点击Login。
将在浏览器上张贴关于未成功登录的信息。
页: 1
步骤1至5。 用户名称为“”和密码为“”。