QA Process Sample:
Requirement ID: 35 | JIRA Ticket Id: AE.UI.11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Requirement Description: UI shall support user logins. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Cucumber Script:
Background: Given I am on the Login page
Scenario Outline: Check if the login page works for valid username/password and doesn’t work for invalid username/password User fill out the Username/Password textboxes .
When user press login button.
Then system checks the DB table to find if it is valid. When username/password is valid. Then the main web page will be presents. When username/password is invalid. Then stay on the login page. And show a text “Invalid username/password. Please try again.”
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Testing using Selenium and Cucumber-JVM
Cucumber is a testing framework which helps in performing acceptance testing, where test scripts are written in a BDD approach. A feature file is created and written in plain english and the corresponding testscripts are driven using selenium.
- The annotations that are commonly used are : Given, And,When,Then, But, Before and After
- A feature file should contain the feature description that tells about the features the test scripts would cover, test scenarios and may contain a background or scenario outline as well.
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-core</artifactId> <version>1.1.5</version> </dependency>
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.1.5</version> </dependency>
<dependency> <groupId>info.cukes</groupId> <artifactId>gherkin-jvm-deps</artifactId><version>1.0.2</version> </dependency>
<dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.1.5</version> </dependency>
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.44.0</version> </dependency> |
---|
Feature File:
Feature: A feature would describe the current testscript that is to be executed
Background: Background describes the steps that would be executed before each scenario
Scenario: Scenario would describe the steps and expected outcome for a particular test case.
Scenario Outline: Using Scenario Outline, we can execute the same scenarios for multiple sets of data. The data is provided in a tabular structure(separated by | |) under Examples. The step definitions can be parameterized by providing the column header in angular brackets(< >). Double quotes for each parameter needs to be put in the table and not in the step definition.
Given: Given specifies the context of the text to be executed. Given step can also be parameterized using datatables.
When: When specifies the test action to be performed
Then: Then specifies the expected outcome of the test
- Parameters can be passed in each step definition within double quotes(“”)
- Tags can be provided for different scenarios, features or backgrounds. The tags would help in determining the specific scripts that would be executed.
- Once the feature file is written, we need to create a test class which would run the feature file definitions. It would look similar as below:
@RunWith(Cucumber.class) @Cucumber.Options(features="/Users/nalipanah/Documents/Repository/Git/cucumber-selenium/src/test/resources/Features/google.feature") public class RunCucumberLoginFeature {
} |
---|
- We need to add the path of the feature file in the cucmber options and then execute the test file
- Since we have not yet prepared test script for each definition. On execution, methods would be created using the step definition phrase and would appear in the console, suggesting that we need to implement these methods in order for the test scripts to be executed successfully. Note that the test methods would be having an underscore format.
public class CucumberLoginTest { WebDriver driver = null;
@After public void close_window() { driver.quit(); }
@Given("^Login Page is open in Firefox.$") public void useropensbrowser() { driver = new FirefoxDriver(); driver.get("https://www.google.com/"); driver.manage().window().maximize(); } |
---|
0 Comments