Cucumber + Java
Introduction to Cucumber Installation of CucumberAdding Cucumber dependency to Java project Writing first cucumber test Executing Cucumber tests using Cucumber class Cucumber options Tagging the scenarios Using name option Passing parameters to steps Key – Value pair Datatable Multiple column datatable in Cucumber Scenario Background Scenario outline Running multiple feature files in Cucumber Sharing selenium Webdriver instance using PicoContainer Embedding the screenshot Writing to Cucumber HTML reports Cucumber dependency for using Lambda expressions in Java 8 Cucumber test using Lambda expressionsname option in cucumber
We can execute the specific scenarios with their names matching typical pattern. For example – Consider below feature file.
@selenium
Feature: My feature
@regression @sanity @critical
Scenario: Verify softpost title
Given I am on the www.softpost.org home page
Then I verify that title contains tutorials
@sanity
Scenario: Verify yahoo title
Given I am on the www.yahoo.com home page
Then I verify that title contains tutorials
To execute only those scenarios with name containing “softpost”, we can use below test class. Note that we can also use regular expression as well to specify the value of scenario name.
package org.softpost;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "classpath:abc.feature",
glue = "classpath:org.softpost",
name = {"softpost"},
plugin = "html:target/selenium-reports"
)
public class MyTest {
}
Web development and Automation testing
solutions delivered!!