Is it possbile to have a null value on Example table on Cucumber Scenario Outline?

12,976

The empty value will be considered a String if the feature step looks something like this:

Given ...
When I enter my "<Username>" and "<Password>"
And I enter my "<Contact>"
And I enter my "<Number>"
Then ...

You can manage the empty string inside the step definition:

@When("^I enter my \"([^\"]*)\"$")
public void I_enter_my(String contact) throws Throwable {
    // Handle empty string as null
    throw new PendingException();
}

Just an exmple, not sure if the code will work. Hope it helps.

Share:
12,976
Sachi
Author by

Sachi

Updated on June 19, 2022

Comments

  • Sachi
    Sachi almost 2 years

    Here is my example table on my scenario outline, some does not have value, is this possible?

    Examples:
    
    |ID   | UserName   | Password  | Contact1 | Number       |
    
    |ID1  | username1  | password1 | Phone    | 111 222 4444 |
    
    |ID2  | username2  | password2 |          |              |
    
    |ID3  | username3  | password3 | Email    | [email protected]      |
    
    |ID4  | username4  | password4 |          |              |