Today we are going to learn how to use Scenario Outline and Examples in cucumber?. If you are new to cucumber functional automated testing than please go through my blog post
Cucumber basic concept
First-of-all create a feature file as LoginTest.feature and add these lines of code in that

Scenario Outline: Successful login as a carer
    Given I go to the start page
    When I enter username "<userName>" and password "<Password>"
    Then I am logged in
    Examples:
        |userName                   |Password |
        |userName1                  |Password1|
        |userName2                  |Password2|
        |userName3                  |Password3|

Scenario Outlines, any

< >

delimited tokens will be substituted with values from the example tables to corresponding step like

import org.junit.Assert
import org.openqa.selenium.By
import static cucumber.api.groovy.EN.*

WebDriver driver = new FirefoxDriver()
Given (~'^I go to the start page$') {->
   driver.get("http://localhost:8080/application")
}

When (~'^I enter username "([^"]*)" and password "([^"]*)"$'){String username, String password ->
   driver.findElement(By.id("j_username")).sendKeys(userName)
   driver.findElement(By.id("j_password")).sendKeys(password)
   driver.findElement(By.id("loginButton")).click()
}

Then (~'^I am logged in$') { ->
   Assert.assertEquals("http://localhost:8080/application/success", driver.getCurrentUrl())
   Assert.assertTrue(driver.findElement(
       By.name("logoutLink")).getText().contains("Logout")
   )
}

Scenario Outline and Examples help us to reduce line of code and it checks one scenario with different inputs.