Created
February 17, 2012 02:44
-
-
Save restagner/1850089 to your computer and use it in GitHub Desktop.
Example of scenario outlines, scenarios and tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@feature_1 | |
Feature: Feature one | |
Scenario: A | |
Given a step in A | |
When an action in A | |
Then the expected outcome is X | |
@feature_2 | |
Scenario Outline: B | |
Given a step in C | |
When an action in B | |
Then the outline's expected outcome is <result> | |
Examples: | |
| result | | |
| Y | | |
| W | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Feature 2 | |
@feature_2 | |
Scenario: C | |
Given a step in C | |
When an action in C | |
Then the expected outcome is Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stag.hello; | |
import org.junit.runner.RunWith; | |
import cucumber.junit.Cucumber; | |
import cucumber.junit.Feature; | |
@RunWith(Cucumber.class) | |
@Feature(tags = {"@feature_1, @feature_2"}, value = "features/") | |
public class HelloTest { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stag.hello; | |
import cucumber.annotation.en.Given; | |
import cucumber.annotation.en.Then; | |
import cucumber.annotation.en.When; | |
public class StepDefsForFeature_1 { | |
@Given("^a step in A$") | |
public void aStepInA() { | |
printMessage("Inside GIVEN step A"); | |
} | |
@When("^an action in A$") | |
public void anActionInA() { | |
printMessage("Inside WHEN step A"); | |
} | |
@Then("^the expected outcome is X$") | |
public void theExpectedOutcomeIsX() { | |
printMessage("Inside THEN step X"); | |
} | |
@When("^an action in B$") | |
public void anActionInB() { | |
printMessage("Inside WHEN step B"); | |
} | |
@Then("^the outline's expected outcome is (.*)$") | |
public void theExpectedOutcomeIsY(String result) { | |
printMessage("Inside THEN step " + result); | |
} | |
private void printMessage(String msg) { | |
System.out.println("[" + StepDefsForFeature_1.class + "]: " + msg); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stag.hello; | |
import cucumber.annotation.Before; | |
import cucumber.annotation.en.Given; | |
import cucumber.annotation.en.Then; | |
import cucumber.annotation.en.When; | |
public class StepDefsForFeature_2 { | |
@Before("@feature_2") | |
public void setup() { | |
printMessage("Inside tagged BEFORE hook -- tag = @feature_2"); | |
} | |
@Given("^a step in C$") | |
public void aStepInC() { | |
printMessage("Inside GIVEN step C"); | |
} | |
@When("^an action in C$") | |
public void anActionInC() { | |
printMessage("Inside WHEN step C"); | |
} | |
@Then("^the expected outcome is Z$") | |
public void theExpectedOutcomeIsZ() { | |
printMessage("Inside THEN step Z"); | |
} | |
private void printMessage(String msg) { | |
System.out.println("[" + StepDefsForFeature_2.class + "]: " + msg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EXPECTED OUTPUT
ACTUAL OUTPUT