9 | * Example of how multiple stories can be run via JUnit, finding steps
10 | * via the {@link ScanningStepsFactory}.
11 | *
12 | */
13 | public class CoreStoriesUsingScanning extends CoreStories {
14 |
15 | @Override
16 | public InjectableStepsFactory stepsFactory() {
17 | return new ScanningStepsFactory(configuration(), "org.jbehave.examples.core.steps").notMatchingNames(
18 | ".*Failing.*");
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/CoreStoriesFailing.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core;
2 |
3 | import static org.jbehave.core.io.CodeLocations.codeLocationFromClass;
4 |
5 | import java.util.List;
6 |
7 | import org.jbehave.core.io.StoryFinder;
8 |
9 | public class CoreStoriesFailing extends CoreStories {
10 |
11 | @Override
12 | public List storyPaths() {
13 | String filter = System.getProperty("story.filter", "**/failing/*.story");
14 | return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), filter,
15 | "**/custom/*.story,**/given/*.story,**/pending/*.story");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/CoreStoriesFailingUponPending.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.failures.FailingUponPendingStep;
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.junit.runner.RunWith;
7 |
8 | @RunWith(JUnit4StoryRunner.class)
9 | public class CoreStoriesFailingUponPending extends CoreStories {
10 |
11 | @Override
12 | public Configuration configuration() {
13 | return super.configuration()
14 | .usePendingStepStrategy(new FailingUponPendingStep());
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/persistence/TraderPersister.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.persistence;
2 |
3 | import org.jbehave.examples.core.model.Trader;
4 |
5 | public class TraderPersister {
6 |
7 | private Trader[] traders;
8 |
9 | public TraderPersister(Trader... traders) {
10 | this.traders = traders;
11 | }
12 |
13 | public Trader retrieveTrader(String name) {
14 | for (Trader trader : traders) {
15 | if (trader.getName().equals(name)) {
16 | return trader;
17 | }
18 | }
19 | return null;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/service/TradingService.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.service;
2 |
3 | import org.jbehave.examples.core.model.Stock;
4 | import org.jbehave.examples.core.model.Trader;
5 |
6 | public class TradingService {
7 |
8 | public Stock newStock(String symbol, double threshold) {
9 | return new Stock(symbol, threshold);
10 | }
11 |
12 | public Trader newTrader(String name, String rank) {
13 | return new Trader(name, rank);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/AbstractSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.When;
4 |
5 | public abstract class AbstractSteps {
6 |
7 | @When("something happens")
8 | public void whenSomethingHappens() {
9 |
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/AndSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.jbehave.core.annotations.When;
5 |
6 | public class AndSteps {
7 | @Given("the wind blows")
8 | public void givenWindBlows() {
9 | System.err.println("given the wind blows");
10 | }
11 |
12 | @When("the wind blows")
13 | public void whenWindBlows() {
14 | System.err.println("when the wind blows");
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/MyContext.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class MyContext {
7 |
8 | Map variables = new HashMap<>();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/ParameterDelimitersSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.jbehave.core.annotations.Named;
5 |
6 | public class ParameterDelimitersSteps {
7 |
8 | @Given("a ")
9 | public void givenAParameterWithAngleBrackets(@Named("parameter") String parameter) {
10 | System.out.println(">>>> parameter " + parameter);
11 | }
12 |
13 | @Given("a [parameter]")
14 | public void givenAParameterWithSquareBrackets(@Named("parameter") String parameter) {
15 | System.out.println(">>>> parameter " + parameter);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/ParametrisedSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.jbehave.core.model.ExamplesTable;
5 |
6 | public class ParametrisedSteps {
7 |
8 | @Given("a parametrised table: $table")
9 | public void givenAParametrisedTable(ExamplesTable table) {
10 | String value = table.getRowAsParameters(0, true).valueAs("value", String.class);
11 | System.out.println(">>>> Replaced row value: " + value);
12 | }
13 |
14 | @Given("a value $value")
15 | public void givenAValue(String value) {
16 | if (value.equals("bad")) {
17 | throw new RuntimeException("Bad value");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/SandpitSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.jbehave.core.annotations.Then;
5 | import org.jbehave.core.steps.Steps;
6 |
7 | public class SandpitSteps extends Steps {
8 |
9 | @Given("I do nothing")
10 | public void doNothing() {
11 | }
12 |
13 | @Then("I fail")
14 | public void doFail() {
15 | throw new AssertionError("I failed!");
16 | }
17 |
18 | @Then("I pass")
19 | public void doPass() {
20 | }
21 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/VerbatimSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.jbehave.core.model.Verbatim;
5 |
6 | public class VerbatimSteps {
7 |
8 | @Given("a verbatim content: $verbatim")
9 | public void givenVerbatimContent(Verbatim verbatim) {
10 | System.out.println(verbatim.getContent());
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/steps/composite.steps:
--------------------------------------------------------------------------------
1 | Composite: Given I have a bank account with balance $balance
2 | Given I have a bank account
3 | Given my balance is
4 |
5 | Composite: Given I have a balance $balance and withdraw $value
6 | Given I have a bank account with balance
7 | When I withdraw
8 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/MetaFiltering.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories;
2 |
3 | import java.util.Arrays;
4 |
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class MetaFiltering extends CoreStory {
8 |
9 | public MetaFiltering() {
10 | // Uncomment to set meta filter, which can also be set via Ant or Maven
11 | configuredEmbedder().useMetaFilters(Arrays.asList("+run yes"));
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/ParameterDelimiters.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.steps.ParameterControls;
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class ParameterDelimiters extends CoreStory {
8 |
9 | @Override
10 | public Configuration configuration() {
11 | return super.configuration().useParameterControls(
12 | new ParameterControls().useNameDelimiterLeft("[").useNameDelimiterRight("]"));
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/PriorityMatching.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories;
2 |
3 | import org.jbehave.examples.core.CoreStory;
4 |
5 | public class PriorityMatching extends CoreStory {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/Restarting.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories;
2 |
3 | import org.jbehave.core.steps.InjectableStepsFactory;
4 | import org.jbehave.core.steps.InstanceStepsFactory;
5 | import org.jbehave.examples.core.CoreStory;
6 | import org.jbehave.examples.core.steps.RestartingSteps;
7 |
8 | public class Restarting extends CoreStory {
9 |
10 | @Override
11 | public InjectableStepsFactory stepsFactory() {
12 | return new InstanceStepsFactory(configuration(), new RestartingSteps());
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/SkipBeforeAndAfterScenarioStepsIfGivenStory.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.embedder.StoryControls;
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class SkipBeforeAndAfterScenarioStepsIfGivenStory extends CoreStory {
8 |
9 | @Override
10 | public Configuration configuration() {
11 | return super.configuration().useStoryControls(
12 | new StoryControls().doSkipBeforeAndAfterScenarioStepsIfGivenStory(true));
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/alias.story:
--------------------------------------------------------------------------------
1 | Scenario: Verify aliases from resources
2 |
3 | Given a plan with Google calendar date of
4 | Then the complainant should receive an amount of
5 | Then the petitioner should receive an amount of
6 |
7 | Examples:
8 | |date |amount|
9 | |none |0.0 |
10 | |01/06/2010 |2.15 |
11 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/and_step.story:
--------------------------------------------------------------------------------
1 | Narrative:
2 | As a story writer
3 | I want to explain the use of And steps and also show that I can use keywords in scenario title and comments
4 | So that I'll be more communicative
5 |
6 | Scenario: And steps should match the previous step type
7 |
8 | Given the wind blows
9 | !-- This And is equivalent to another Given
10 | And the wind blows
11 | !-- This And shows that we can chain multiple And steps
12 | And the wind blows
13 | When the wind blows
14 | !-- This And is equivalent to another When
15 | And the wind blows
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/calendar.story:
--------------------------------------------------------------------------------
1 | Given a plan with calendar date of
2 | Then the claimant should receive an amount of
3 |
4 | Examples:
5 | |date |amount|
6 | |none |0.0 |
7 | |01/06/2010 |2.15 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/context.story:
--------------------------------------------------------------------------------
1 |
2 | Meta: @skip
3 |
4 | Scenario: One
5 |
6 | When a variable of name one is processed
7 | Then the context includes the name one
8 |
9 | Scenario: Two
10 |
11 | When a variable of name two is processed
12 | Then the context includes the name two
13 | And the context does not include the name one
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/custom/synonyms.story:
--------------------------------------------------------------------------------
1 | Narrative:
2 | As a story writer
3 | I want to use synonyms
4 | So that I'll be more communicative
5 |
6 | Scenario: And steps using With synonyms
7 |
8 | Given the wind blows
9 | With the wind blows
10 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/do_nothing.story:
--------------------------------------------------------------------------------
1 |
2 | !-- GivenStories: ignore_me.story
3 |
4 | Given I do nothing
5 |
6 | !-- Examples:
7 | |I|am|just|lazy|
8 |
9 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/ExamplesTableFailing.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.failing;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.examples.core.CoreStory;
5 |
6 | public class ExamplesTableFailing extends CoreStory {
7 |
8 | @Override
9 | public Configuration configuration() {
10 | Configuration configuration = super.configuration();
11 | configuration.storyControls().doResetStateBeforeScenario(false);
12 | return configuration;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/FailingBeforeAfter.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.failing;
2 |
3 | import org.jbehave.core.steps.InjectableStepsFactory;
4 | import org.jbehave.core.steps.InstanceStepsFactory;
5 | import org.jbehave.examples.core.CoreStory;
6 | import org.jbehave.examples.core.service.TradingService;
7 | import org.jbehave.examples.core.steps.FailingBeforeAfterSteps;
8 | import org.jbehave.examples.core.steps.TraderSteps;
9 |
10 | public class FailingBeforeAfter extends CoreStory {
11 |
12 | @Override
13 | public InjectableStepsFactory stepsFactory() {
14 | return new InstanceStepsFactory(configuration(), new TraderSteps(new TradingService()),
15 | new FailingBeforeAfterSteps());
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/SkipScenariosAfterFailure.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.failing;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.embedder.StoryControls;
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class SkipScenariosAfterFailure extends CoreStory {
8 |
9 | @Override
10 | public Configuration configuration() {
11 | return super.configuration().useStoryControls(new StoryControls().doSkipScenariosAfterFailure(true)
12 | .doSkipBeforeAndAfterScenarioStepsIfGivenStory(true));
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/SkipStoryIfGivenStoryFailed.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.failing;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.embedder.StoryControls;
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class SkipStoryIfGivenStoryFailed extends CoreStory {
8 |
9 | @Override
10 | public Configuration configuration() {
11 | return super.configuration().useStoryControls(new StoryControls().doSkipStoryIfGivenStoryFailed(true));
12 | }
13 |
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/after_scenario_outcome.story:
--------------------------------------------------------------------------------
1 | Story: Showing that @AfterScenario method are executed upon appropriate outcome (ANY, SUCCESS, FAILURE)
2 |
3 | Scenario: Pass on a step
4 |
5 | Given I do nothing
6 | Then I pass
7 |
8 | Scenario: Fail on a step
9 |
10 | Given I do nothing
11 | Then I fail
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/and_step.story:
--------------------------------------------------------------------------------
1 | Scenario: An initial And step should be marked as pending as there is not previous step
2 |
3 | !-- What is this And of? JBehave treats as pending
4 | And the wind blows
5 | !-- Look Ma' - I can also use keywords in scenario title and step comments!
6 |
7 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/examples_table_failing.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parametrisation
4 |
5 | Scenario: State of parametrised scenarios is not reset, thus the final state will be a failure
6 |
7 | Given a value
8 |
9 | Examples:
10 | |value|
11 | |bad|
12 | |good|
13 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failing_after_stories.story:
--------------------------------------------------------------------------------
1 | We want to show that failures in @AfterStories methods will appear in the AfterStories report.
2 |
3 | Scenario:
4 |
5 | Given the alert status is OFF
6 | Given a trader of name Mauro
7 | And the alert status is OFF
8 | Given a stock of symbol STK1 and a threshold of 1.5
9 | When the stock is traded at price 2.0
10 | Then the alert status is ON
11 | When the trader sells all stocks
12 | Then the trader is left with no stocks
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failing_before_after.story:
--------------------------------------------------------------------------------
1 | We want to show that failures in @BeforeScenario methods will not prevent rest of scenario steps to run (marked as NOT PERFORMED).
2 | Also, the @Before/AfterScenario, @Before/AfterStory failure messages should be displayed in the story reports, while
3 | the @BeforeAfterStories failures are displayed in the Before/AfterStories reports.
4 |
5 | Scenario:
6 |
7 | Given the alert status is OFF
8 | Given a trader of name Mauro
9 | And the alert status is OFF
10 | Given a stock of symbol STK1 and a threshold of 1.5
11 | When the stock is traded at price 2.0
12 | Then the alert status is ON
13 | When the trader sells all stocks
14 | Then the trader is left with no stocks
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failing_before_stories.story:
--------------------------------------------------------------------------------
1 | We want to show that failures in @BeforeStories methods will mark rest of steps as NOT PERFORMED, if story and scenario state is not reset via the StoryControls
2 |
3 | Scenario:
4 |
5 | Given the alert status is OFF
6 | Given a trader of name Mauro
7 | And the alert status is OFF
8 | Given a stock of symbol STK1 and a threshold of 1.5
9 | When the stock is traded at price 2.0
10 | Then the alert status is ON
11 | When the trader sells all stocks
12 | Then the trader is left with no stocks
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failure_correlation_one.story:
--------------------------------------------------------------------------------
1 | Scenario: Fail on a step in story 1
2 |
3 | When a failure occurs in story 1
4 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failure_correlation_two.story:
--------------------------------------------------------------------------------
1 | Scenario: Fail on a step in story 2
2 |
3 | When a failure occurs in story 2
4 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/failure_followed_by_given_stories.story:
--------------------------------------------------------------------------------
1 | Story: Showing that using given stories in a passing scenario following a scenario where are a failure occurred resets the overall
2 | build result of the story
3 |
4 | Scenario: Fail on a step
5 |
6 | Given I do nothing
7 | Then I fail
8 |
9 | Scenario: Pass after given stories
10 |
11 | GivenStories: org/jbehave/examples/core/stories/do_nothing.story
12 |
13 | Given I do nothing
14 | Then I pass
15 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/given_non_successful.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that depends on a non successful story
2 |
3 | GivenStories: org/jbehave/examples/core/stories/failing/non_successful.story
4 |
5 | Given the traders:
6 | |name |rank |
7 | |Larry|Stooge 3|
8 | |Moe |Stooge 1|
9 | |Curly|Stooge 2|
10 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/lifecycle.story:
--------------------------------------------------------------------------------
1 | Story: Showing lifecycle behaviour
2 |
3 | Lifecycle:
4 | Before:
5 |
6 | Given I have a bank account
7 | And my balance is 100
8 |
9 | After:
10 | Outcome: ANY
11 | Then my balance is printed
12 |
13 | Outcome: SUCCESS
14 | Then my balance is archived
15 |
16 | Outcome: FAILURE
17 | MetaFilter: +non-archiving
18 | Then my balance is not archived
19 |
20 | Scenario: Failing archiving scenario
21 | Meta: @archiving
22 |
23 | When I withdraw 10
24 | Then my bank account balance should be 100
25 |
26 | Scenario: Failing non-archiving scenario
27 | Meta: @non-archiving
28 |
29 | When I withdraw 10
30 | Then my bank account balance should be 100
31 |
32 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/non_successful.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario with failed step
2 |
3 | Then I fail
4 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/skip_scenarios_after_failure.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario with failed step
2 |
3 | Given I do nothing
4 | Then I fail
5 |
6 | Scenario: A scenario that is not executed because if followed a failed scenario
7 |
8 | Given I do nothing
9 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/skip_story_if_given_story_failed.story:
--------------------------------------------------------------------------------
1 | GivenStories: org/jbehave/examples/core/stories/failing/non_successful.story
2 |
3 | Scenario: A scenario that is not executed because it followed a failed given story
4 |
5 | Given I do nothing
6 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/failing/traders_can_be_searched.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: Traders search fails
3 |
4 | Given the trader ranks:
5 | |name |rank |
6 | |Larry|Stooge 3|
7 | |Moe |Stooge 1|
8 | |Curly|Stooge 2|
9 | !-- Verification fails
10 | Then the traders returned are:
11 | |name |rank |
12 | |Moe |Stooge 1|
13 | |Curly|Stooge 2|
14 |
15 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given/GivenStoriesLoadedByRelativePath.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.given;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.io.RelativePathCalculator;
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class GivenStoriesLoadedByRelativePath extends CoreStory {
8 |
9 | @Override
10 | public Configuration configuration() {
11 | return super.configuration().usePathCalculator(new RelativePathCalculator());
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given/given_stories_loaded_by_relative_path.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parametrisation
4 |
5 | Scenario: A scenario that depends on a story loaded with relative path
6 |
7 | GivenStories: parametrised.story#{0}
8 |
9 | When the stock is traded at price 1.1
10 | Then the alert status is ON
11 |
12 | Examples:
13 | |symbol|threshold|
14 | |STK1 |1.0|
15 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given/parametrised.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parametrisation
4 |
5 | Scenario:
6 |
7 | Given the asset class
8 | Given a stock of and a
9 |
10 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given/scenarios.story:
--------------------------------------------------------------------------------
1 | Scenarios that are used as preconditions, used via given stories /path/to/story#{idX:scenarioX}
2 |
3 | Scenario: Scenario 1
4 |
5 | Meta: @id1 scenario1
6 |
7 | Given a stock of symbol XXX and a threshold of 1.0
8 |
9 | Scenario: Scenario 2
10 |
11 | Meta: @id2 scenario2
12 |
13 | Given a stock of symbol XXX and a threshold of 2.0
14 |
15 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given_stories_filtered_by_meta.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that depends on a given scenario that does not have matching meta info,
2 | but the meta filter is ignored in the given story
3 | Meta: @run
4 |
5 | GivenStories: org/jbehave/examples/core/stories/given/scenarios.story#{id1:scenario1}
6 |
7 | When the stock is traded at price 1.1
8 | Then the alert status is ON
9 |
10 | Scenario: A scenario that depends on another given scenario
11 | Meta: @skip
12 |
13 | GivenStories: org/jbehave/examples/core/stories/given/scenarios.story#{id2:scenario2}
14 |
15 | When the stock is traded at price 1.1
16 | Then the alert status is OFF
17 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given_stories_filtered_by_scenario_id.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that depends on a given scenario
2 |
3 | GivenStories: org/jbehave/examples/core/stories/given/scenarios.story#{id1:scenario1}
4 |
5 | When the stock is traded at price 1.1
6 | Then the alert status is ON
7 |
8 | Scenario: A scenario that depends on another given scenario
9 |
10 | GivenStories: org/jbehave/examples/core/stories/given/scenarios.story#{id2:scenario2}
11 |
12 | When the stock is traded at price 1.1
13 | Then the alert status is OFF
14 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given_stories_parametrised_by_anchor.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that depends on a given story with parameters specified as anchor pointing to specific examples row.
2 | The presence of the anchor implies that the scenario is executed normally and not parametrised by examples, i.e. that the scenario is not executed for each examples row.
3 |
4 | Meta: @theme parametrisation
5 | @assetClass FX
6 |
7 | GivenStories: org/jbehave/examples/core/stories/given/parametrised.story#{0}
8 |
9 | When the stock is traded at price 1.1
10 | Then the alert status is ON
11 |
12 | Examples:
13 | |symbol|threshold|
14 | |STK1 |1.0|
15 | |STK2 |2.0|
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given_stories_parametrised_by_examples.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that depends on given stories parametrised by examples.
2 | Here the entire scenario is parametrised by examples, i.e. the scenario is executed for each examples row.
3 |
4 | Meta: @assetClass FX
5 |
6 | GivenStories: org/jbehave/examples/core/stories/select_stock_exchange.story
7 |
8 | Given a stock of symbol and a threshold of
9 | When the stock is traded at price
10 | Then the alert status is
11 |
12 | Examples:
13 | |stockExchange|symbol|threshold|price|status|
14 | |NASDAQ|STK1|10.0|5.0|OFF|
15 | |FTSE|STK1|10.0|11.0|ON|
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/given_stories_parametrised_by_meta.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that is executed after the given stories parametrised by meta
2 |
3 | Meta: @theme parametrisation
4 | @assetClass FX @symbol STK1 @threshold 1.0
5 |
6 | GivenStories: org/jbehave/examples/core/stories/given/parametrised.story
7 |
8 | When the stock is traded at price 1.1
9 | Then the alert status is ON
10 |
11 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/ignoring.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: Ignoring steps after first
3 |
4 | Given a successful step
5 | When ignore steps failure occurs
6 | Then step is ignored
7 | Then step is ignored
8 |
9 | Scenario: A new step of steps
10 |
11 | Given a successful step
12 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/lifecycle_scope.story:
--------------------------------------------------------------------------------
1 | Story: Showing lifecycle behaviour with both scenario and story scope
2 |
3 | Lifecycle:
4 | Before:
5 | Scope: STORY
6 | Given I have a bank account
7 |
8 | Scope: SCENARIO
9 | Given my balance is 100
10 |
11 | Scope: STEP
12 | When I withdraw 2
13 |
14 | After:
15 | Scope: STORY
16 | Then my balance is archived
17 |
18 | Scope: SCENARIO
19 | Then my balance is in credit
20 |
21 | Scope: STEP
22 | When I withdraw 1
23 |
24 | Scenario: First scenario
25 | When I withdraw 10
26 | Then my bank account balance should be 85
27 |
28 | Scenario: Second scenario
29 | When I withdraw 20
30 | Then my bank account balance should be 75
31 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/meta_filtering.story:
--------------------------------------------------------------------------------
1 | A story description
2 | over multiple lines
3 |
4 | Meta:
5 |
6 | !-- A first ignored comment
7 | @theme filtering
8 | !-- Another ignored comment
9 | @author Mauro
10 |
11 | Scenario: A scenario to be skipped
12 | and not executed
13 |
14 | Meta:
15 |
16 | @skip
17 |
18 | Given I do nothing
19 |
20 | Scenario: A scenario with an author
21 |
22 | Meta:
23 |
24 | Given I do nothing
25 |
26 | Scenario: A scenario with examples whose rows can be filtered on meta
27 |
28 | Meta: @run
29 |
30 | Given I do nothing
31 |
32 | Examples:
33 | |Meta:|Parameter|
34 | |@run yes|value|
35 | |@run not|value|
36 |
37 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/meta_parametrisation.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parameters
4 |
5 | Scenario: scenario with explicitly mentioned meta params
6 |
7 | Meta:
8 |
9 | @variant named
10 |
11 | Given I have specified the
12 | And a
13 | Then the theme is 'parameters' with variant 'named'
14 |
15 |
16 | Scenario: scenario with hidden meta params
17 |
18 | Meta:
19 |
20 | @variant foo
21 |
22 | Given I have some step that implicitly requires meta params
23 | Then the theme is 'parameters' with variant 'foo'
24 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/named_parameters.story:
--------------------------------------------------------------------------------
1 | Scenario: We want to verify that parameters can be matched by name preserving the natural order
2 |
3 | Given parameters matched by name in natural order one and two
4 | Then parameters values are one and two
5 |
6 | Scenario: We want to verify that parameters can be matched by name inverting the natural order
7 |
8 | Given parameters matched by name in inverse order one and two
9 | Then parameters values are one and two
10 |
11 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/parameter_delimiters.story:
--------------------------------------------------------------------------------
1 | Scenario: I want to show that different parameter delimiters can be configured via the ParameterControls
2 |
3 | Given a [parameter]
4 |
5 | Examples:
6 | |parameter|
7 | |value|
8 |
9 | Scenario: I want to show that parameter values are correctly delimited, even when the values are overlapping
10 |
11 | Given a stock of symbol 10ABCDEF and a threshold of 10
12 | Given a stock of symbol ABC10DEF and a threshold of 10
13 | Given a stock of symbol ABCDEF10 and a threshold of 10
14 |
15 | Scenario: I want to show that parameter values are correctly delimited, but not in the table parameter
16 |
17 | Given the traders:
18 | |name | rank |
19 | |joe | topdog |
20 | And a stock of symbol topdog and a threshold of 10
21 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/parametrised_scenario.story:
--------------------------------------------------------------------------------
1 | Scenario: Parameter does match examples table header
2 |
3 | Given that I am on Google's Homepage
4 | When I enter the search term and proceed
5 | Then I should see ridiculous things
6 |
7 | Examples:
8 | |ridiculousSearchTerm|
9 | |Hello Kitty|
10 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/parametrised_table.story:
--------------------------------------------------------------------------------
1 |
2 | Given a parametrised table:
3 | |name|value|
4 | |name1|scheme|
5 |
6 | Examples:
7 | |scheme|
8 | |scheme1|
9 | |scheme2|
10 | |scheme3|
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/pending/MetaFiltering.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.stories.pending;
2 |
3 | import java.util.Arrays;
4 |
5 | import org.jbehave.examples.core.CoreStory;
6 |
7 | public class MetaFiltering extends CoreStory {
8 |
9 | public MetaFiltering() {
10 | // Uncomment to set meta filter, which can also be set via Ant or Maven
11 | configuredEmbedder().useMetaFilters(Arrays.asList("+run yes"));
12 | }
13 |
14 | }
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/pending/meta_filtering.story:
--------------------------------------------------------------------------------
1 | A story description
2 | over multiple lines
3 |
4 | Meta:
5 |
6 | !-- A first ignored comment
7 | @theme filtering
8 | !-- Another ignored comment
9 | @author Mauro
10 |
11 |
12 | Scenario: A parametrised scenario that is yet to be implemented
13 |
14 | Meta:
15 | @run pending
16 |
17 | When I lookup my
18 | Then I will see
19 |
20 | Examples:
21 | | car reservation | car type |
22 | | 1223395844 | midsize |
23 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/pending/parametrised_scenario.story:
--------------------------------------------------------------------------------
1 | Scenario: Parameter does not match examples table header and step is marked as pending
2 |
3 | Given that I am on Google's Homepage
4 | When I enter the search term and proceed
5 | Then I should see ridiculous things
6 |
7 | Examples:
8 | |ridiculoussearchterm|
9 | |Hello Kitty|
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/pending/pending_stats.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: A scenario with no steps
3 |
4 | Scenario: A scenario with some pending steps
5 |
6 | Given I am pending
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/pending/step_composition.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parametrisation
4 |
5 | Scenario: Using a composite step where one of the composed steps is not found.
6 | The composed step not found should be reported as pending and the subsequent composed steps not performed.
7 |
8 | !-- Annotated method:
9 | !-- @Given("%customer returns to cart")
10 | !-- @Composite(steps = { "Given step not found",
11 | !-- "Given has a cart", })
12 | !-- public void compositeStep(@Named("customer") String customer) { // composed steps use these named parameters
13 | !-- }
14 |
15 | Given Mr Jones returns to cart
16 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/priority_matching.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario that verifies priority matching of steps, with the less-greedy pattern given higher priority
2 |
3 | !-- Matching regex "a step that has %param"
4 | Given a step that has a parameter
5 | Then the parameter value is "a parameter"
6 | !-- Matching regex "a step that has exactly one %param"
7 | Given a step that has exactly one of the parameters
8 | Then the parameter value is "of the parameters"
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/restarting.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: Restarting scenario
3 |
4 | When I restart scenario
5 | Then scenario has been executed two times
6 |
7 | Scenario: Restarting story
8 |
9 | When I restart story
10 | Then story has been executed two times
11 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/select_stock_exchange.story:
--------------------------------------------------------------------------------
1 |
2 | Given the stock exchange
3 | And the asset class
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/skip_before_and_after_scenario_steps_if_given_story.story:
--------------------------------------------------------------------------------
1 | Scenario: A scenario where before and after steps are executed only once even if there is a given story
2 |
3 | GivenStories: org/jbehave/examples/core/stories/given/parametrised.story#{0}
4 |
5 | When the stock is traded at price 1.1
6 | Then the alert status is ON
7 |
8 | Examples:
9 | |symbol|threshold|
10 | |STK1 |1.0|
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/step_composition_from_definition_file.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme parametrisation
4 |
5 | Scenario: Using a composite step with normal parameter matching
6 |
7 | Given I have a bank account with balance 50
8 | When I withdraw 10
9 | Then my bank account balance should be 40
10 |
11 |
12 | Scenario: Using a composite step in a parameterised scenario
13 |
14 | Given I have a bank account with balance
15 | When I withdraw 15
16 | Then my bank account balance should be 25
17 |
18 | Examples:
19 | |startBalance|
20 | |40 |
21 |
22 |
23 | Scenario: Composite nested steps in action.
24 |
25 | Given I have a balance 80 and withdraw 20
26 | Then my bank account balance should be 60
27 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/step_nested_composition.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: Composite nested steps in action.
3 |
4 | Then all buttons are enabled
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/steps_context.story:
--------------------------------------------------------------------------------
1 | Narrative:
2 | In order to share variables between steps classes
3 | As a scenario writer
4 | I want to use a steps context to handle it for me
5 |
6 | Scenario: Steps Context in action
7 |
8 | When a variable with value myValue is stored in steps context
9 | Then the steps context includes the value myValue
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/table_parameters.story:
--------------------------------------------------------------------------------
1 | Scenario: Table parameters
2 |
3 | Given the table as parameter:
4 | |name |rank |
5 | |Larry|Stooge 1|
6 | |Moe |Stooge 2|
7 | |Curly|Stooge 3|
8 | Given the table of type TYPE as parameter:
9 | |name |rank |
10 | |Larry|Stooge 1|
11 | |Moe |Stooge 2|
12 | |Curly|Stooge 3|
13 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/table_transformers.story:
--------------------------------------------------------------------------------
1 | Scenario: Table can be in landscape format
2 |
3 | Given the table:
4 | |name |Larry |Moe |Curly |
5 | |rank |Stooge 1|Stooge 2|Stooge 3|
6 | Then the table transformed by FROM_LANDSCAPE is:
7 | |name|rank|
8 | |Larry|Stooge 1|
9 | |Moe|Stooge 2|
10 | |Curly|Stooge 3|
11 |
12 | Scenario: Table can be formatted
13 |
14 | Given the table:
15 | | name | rank |
16 | | Larry|Stooge 1 |
17 | | Moe | Stooge 2 |
18 | | Curly| Stooge 3|
19 | Then the table transformed by FORMATTING is:
20 | |name |rank |
21 | |Larry|Stooge 1|
22 | |Moe |Stooge 2|
23 | |Curly|Stooge 3|
24 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/trade_types.story:
--------------------------------------------------------------------------------
1 | Trade Types
2 |
3 | Scenario: Trader uses enums to identify trade types
4 |
5 | Given a trade type SELL
6 | Then the current trade type is SELL
7 | And the list of trade types is BUY,SELL
8 |
9 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/traders.table:
--------------------------------------------------------------------------------
1 | |name |rank |
2 | |Larry|Stooge 3|
3 | |Moe |Stooge 1|
4 | |Curly|Stooge 2|
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/trades.table:
--------------------------------------------------------------------------------
1 | |symbol|threshold|price|status|
2 | |STK1 |15.0|5.0 |OFF|
3 | |STK1 |15.0|11.0|OFF|
4 | |STK1 |15.0|16.0|ON |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/trades_transposed.table:
--------------------------------------------------------------------------------
1 | {transformer=FROM_LANDSCAPE, headerSeparator=!, valueSeparator=!}
2 | !symbol !STK1!STK1!STK1!
3 | !threshold!15.0!15.0!15.0!
4 | !price !5.0 !11.0!16.0!
5 | !status !OFF !OFF !ON !
6 |
--------------------------------------------------------------------------------
/examples/core/src/main/java/org/jbehave/examples/core/stories/verbatim.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: Rendering verbatim content in steps
3 |
4 | Given a verbatim content:
5 | Some content I want to render
6 | as is, without any changes
7 |
--------------------------------------------------------------------------------
/examples/core/src/main/resources/alias/aliases.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Given a plan with calendar date of ",
4 | "aliases" : [
5 | {
6 | "name": "Given a plan with Google calendar date of "
7 | }
8 | ]
9 | },
10 | {
11 | "name": "Then the claimant should receive an amount of ",
12 | "aliases" : [
13 | {
14 | "name": "Then the complainant should receive an amount of "
15 | },
16 | {
17 | "name": "Then the petitioner should receive an amount of "
18 | }
19 | ]
20 | }
21 | ]
22 |
--------------------------------------------------------------------------------
/examples/core/src/main/resources/i18n/custom_en.properties:
--------------------------------------------------------------------------------
1 | And=And|With
2 |
--------------------------------------------------------------------------------
/examples/executable-jar/src/main/java/org/jbehave/examples/executablejar/steps/MySteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.executablejar.steps;
2 |
3 | import org.jbehave.core.annotations.Alias;
4 | import org.jbehave.core.annotations.Then;
5 | import org.jbehave.core.annotations.When;
6 |
7 | public class MySteps {
8 | @When("I run this as executable jar")
9 | @Alias("this")
10 | public void whenIRunThisAsExecutableJar() {
11 | // we don't do anything
12 | }
13 |
14 | @Then("this story should run")
15 | @Alias("that")
16 | public void thenThisStoryShouldRun() {
17 | // we don't do anything
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/executable-jar/src/main/resources/org/jbehave/examples/executablejar/stories/jar.story:
--------------------------------------------------------------------------------
1 | Scenario: This should work as executable jar
2 |
3 | When I run this as executable jar
4 | Then this story should run
5 |
6 |
--------------------------------------------------------------------------------
/examples/executable-jar/src/main/resources/org/jbehave/examples/executablejar/stories/jar2.story:
--------------------------------------------------------------------------------
1 | Scenario: This should work as executable jar
2 |
3 | When this
4 | Then that
5 |
6 |
--------------------------------------------------------------------------------
/examples/gherkin/src/main/java/org/jbehave/examples/gherkin/features/using_gherkin.feature:
--------------------------------------------------------------------------------
1 | @feature
2 | Feature: Hello Car
3 |
4 | Background:
5 |
6 | Given I have a license
7 |
8 | @scenario
9 | Scenario: Car can drive
10 |
11 | Given I have a car
12 | Then I can drive them according to wheels:
13 | | wheels | can_drive |
14 | | 1 | false |
15 | | 2 | false |
16 | | 3 | false |
17 | | 4 | true |
18 |
--------------------------------------------------------------------------------
/examples/google/src/main/java/org/jbehave/examples/google/steps/a_story.odt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jbehave/jbehave-core/9c593a132f4530368a4f8b6dd816c0ecbbb6fa09/examples/google/src/main/java/org/jbehave/examples/google/steps/a_story.odt
--------------------------------------------------------------------------------
/examples/google/src/main/java/org/jbehave/examples/google/steps/a_story.txt:
--------------------------------------------------------------------------------
1 | Narrative:
2 | In order to communicate better
3 | As a story writer
4 | I want to be able to use ODT format
5 |
6 | Scenario: a plain scenario
7 | Given a step
8 | When a step has failed
9 | Then the scenario is visualized as failed
10 |
11 | Scenario: a scenario with a given story
12 |
13 | GivenStories: stories/a_successful_story.odt
14 |
15 | Given a step
16 | And the step is successful
17 | Then the scenario is visualized as succeeded
18 |
19 | Scenario: a scenario with examples
20 |
21 | Given a
22 | When the is executed
23 | Then the result is
24 |
25 | Examples:
26 | |step|result|
27 | |one|1|
28 | |two|2|
29 |
--------------------------------------------------------------------------------
/examples/google/src/main/java/org/jbehave/examples/google/stories/load_odt_from_google.story:
--------------------------------------------------------------------------------
1 |
2 | Scenario: A document is loaded from Google Docs.
3 | The credentials are provided via env vars GOOGLE_USER and GOOGLE_PASSWORD.
4 | The doc a_story.odt must be loaded to Google Docs.
5 |
6 | Given Google feed https://docs.google.com/feeds/default/private/full/
7 | When story a_story is loaded from feed
8 | Then content is same as org/jbehave/examples/google/steps/a_story.txt
--------------------------------------------------------------------------------
/examples/grid/src/main/java/org/jbehave/examples/grid/domain/Cell.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.grid.domain;
2 |
3 | import org.apache.commons.lang3.builder.EqualsBuilder;
4 | import org.apache.commons.lang3.builder.HashCodeBuilder;
5 |
6 | public class Cell {
7 |
8 | private final int column;
9 | private final int row;
10 |
11 | public Cell(int column, int row) {
12 | this.column = column;
13 | this.row = row;
14 | }
15 |
16 | @Override
17 | public int hashCode() {
18 | return HashCodeBuilder.reflectionHashCode(this, false);
19 | }
20 |
21 | @Override
22 | public boolean equals(Object obj) {
23 | return EqualsBuilder.reflectionEquals(this, obj, false);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/examples/grid/src/main/java/org/jbehave/examples/grid/domain/Grid.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.grid.domain;
2 |
3 | public interface Grid {
4 |
5 | Grid NULL = new Grid() {
6 | @Override
7 | public int getHeight() {
8 | return 0;
9 | }
10 |
11 | @Override
12 | public int getWidth() {
13 | return 0;
14 | }
15 |
16 | @Override
17 | public boolean cellToggledAt(int column, int row) {
18 | return false;
19 | }
20 | };
21 |
22 | int getWidth();
23 |
24 | int getHeight();
25 |
26 | boolean cellToggledAt(int column, int row);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/examples/grid/src/main/java/org/jbehave/examples/grid/domain/GridObserver.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.grid.domain;
2 |
3 | public interface GridObserver {
4 |
5 | GridObserver NULL = new GridObserver() {
6 | @Override
7 | public void gridChanged(Grid grid) {
8 | }
9 | };
10 |
11 | void gridChanged(Grid grid);
12 | }
13 |
--------------------------------------------------------------------------------
/examples/grid/src/main/java/org/jbehave/examples/grid/stories/grid_cells_can_be_toggled.story:
--------------------------------------------------------------------------------
1 | Scenario: The grid starts empty
2 |
3 | Given a new game: 5 by 5
4 | Then the grid should be
5 | .....
6 | .....
7 | .....
8 | .....
9 | .....
10 |
11 | Scenario: The grid cells can be toggled
12 |
13 | Given a 5 by 5 game
14 | When I toggle the cell at (2, 3)
15 | Then the grid should look like
16 | .....
17 | .....
18 | .....
19 | ..X..
20 | .....
21 | When I toggle the cell at (2, 4)
22 | Then the grid should look like
23 | .....
24 | .....
25 | .....
26 | ..X..
27 | ..X..
28 | When I toggle the cell at (2, 3)
29 | Then the grid should look like
30 | .....
31 | .....
32 | .....
33 | .....
34 | ..X..
35 |
--------------------------------------------------------------------------------
/examples/groovy/src/main/groovy/org/jbehave/examples/groovy/configuration/MyReporterBuilder.groovy:
--------------------------------------------------------------------------------
1 | import org.jbehave.core.reporters.StoryReporterBuilder
2 |
3 | import static org.jbehave.core.reporters.StoryReporterBuilder.Format.*
4 |
5 | class MyReportBuilder extends StoryReporterBuilder {
6 | public MyReportBuilder() {
7 | this.withFormats(CONSOLE, TXT, HTML, XML).withDefaultFormats();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/groovy/src/main/java/org/jbehave/examples/groovy/stories/using_groovy.story:
--------------------------------------------------------------------------------
1 | Scenario: We show that the following steps can be implemented using groovy
2 | (in src/main/groovy)
3 |
4 | Meta: @lang groovy
5 |
6 | Given a date of 10/16/2010
7 | When 2 days pass
8 | Then the date is 10/18/2010
9 | And some otherwise ambiguous two string step, with one and two as strings
10 |
--------------------------------------------------------------------------------
/examples/guice/src/main/java/org/jbehave/examples/core/guice/GuiceCoreSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.guice;
2 |
3 | import com.google.inject.Inject;
4 |
5 | import org.jbehave.examples.core.service.TradingService;
6 | import org.jbehave.examples.core.steps.TraderSteps;
7 |
8 | /**
9 | * POJO annotated to allow Guice injection.
10 | */
11 | public class GuiceCoreSteps extends TraderSteps {
12 |
13 | @Inject
14 | public GuiceCoreSteps(TradingService service) {
15 | super(service);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/DeStories.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n;
2 |
3 | import java.util.Locale;
4 |
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.jbehave.examples.trader.i18n.steps.DeSteps;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(JUnit4StoryRunner.class)
10 | public class DeStories extends LocalizedStories {
11 |
12 | @Override
13 | protected Locale locale() {
14 | return new Locale("de");
15 | }
16 |
17 | @Override
18 | protected String storyPattern() {
19 | return "**/*.geschichte";
20 | }
21 |
22 | @Override
23 | protected Object localizedSteps() {
24 | return new DeSteps();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/FrStories.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n;
2 |
3 | import java.util.Locale;
4 |
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.jbehave.examples.trader.i18n.steps.FrSteps;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(JUnit4StoryRunner.class)
10 | public class FrStories extends LocalizedStories {
11 |
12 | @Override
13 | protected Locale locale() {
14 | return new Locale("fr");
15 | }
16 |
17 | @Override
18 | protected String storyPattern() {
19 | return "**/*.histoire";
20 | }
21 |
22 | @Override
23 | protected Object localizedSteps() {
24 | return new FrSteps();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/ItStories.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n;
2 |
3 | import java.util.Locale;
4 |
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.jbehave.examples.trader.i18n.steps.ItSteps;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(JUnit4StoryRunner.class)
10 | public class ItStories extends LocalizedStories {
11 |
12 | @Override
13 | protected Locale locale() {
14 | return new Locale("it");
15 | }
16 |
17 | @Override
18 | protected String storyPattern() {
19 | return "**/*.storia";
20 | }
21 |
22 | @Override
23 | protected Object localizedSteps() {
24 | return new ItSteps();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/PtStories.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n;
2 |
3 | import java.util.Locale;
4 |
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.jbehave.examples.trader.i18n.steps.PtSteps;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(JUnit4StoryRunner.class)
10 | public class PtStories extends LocalizedStories {
11 |
12 | @Override
13 | protected Locale locale() {
14 | return new Locale("pt");
15 | }
16 |
17 | @Override
18 | protected String storyPattern() {
19 | return "**/*.historia";
20 | }
21 |
22 | @Override
23 | protected Object localizedSteps() {
24 | return new PtSteps();
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/SvStories.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n;
2 |
3 | import java.util.Locale;
4 |
5 | import org.jbehave.core.junit.JUnit4StoryRunner;
6 | import org.jbehave.examples.trader.i18n.steps.SvSteps;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(JUnit4StoryRunner.class)
10 | public class SvStories extends LocalizedStories {
11 |
12 | @Override
13 | protected Locale locale() {
14 | return new Locale("sv");
15 | }
16 |
17 | @Override
18 | protected String storyPattern() {
19 | return "**/*.story";
20 | }
21 |
22 | @Override
23 | protected Object localizedSteps() {
24 | return new SvSteps();
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/steps/SvSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.trader.i18n.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 |
5 | public class SvSteps {
6 |
7 | @Given("att vi finns")
8 | public void exist() {
9 | System.out.println("Exists");
10 | }
11 |
12 | @Given("att det har startat")
13 | public void started() {
14 | System.out.println("Started");
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/examples/i18n/src/main/java/org/jbehave/examples/trader/i18n/stories/sv_and_step.story:
--------------------------------------------------------------------------------
1 | Givet att vi finns
2 | Och att vi finns
3 | Och att det har startat
4 |
5 |
--------------------------------------------------------------------------------
/examples/jruby/src/main/java/org/jbehave/examples/jruby/stories/using_jruby.story:
--------------------------------------------------------------------------------
1 | Scenario: We want to show how steps can be implemented in a class written in JRuby
2 |
3 | Given a date of 10/16/2010
4 | When 2 days pass
5 | Then the date is 10/18/2010
6 |
--------------------------------------------------------------------------------
/examples/jruby/src/main/ruby/JRubySteps.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 |
3 | java_package 'org.jbehave.examples.jruby'
4 |
5 | class JRubySteps
6 |
7 | java_annotation 'org.jbehave.core.annotations.Given("a date of $date")'
8 | java_signature 'void givenDate(java.util.Date)'
9 | def date(date)
10 | org.junit.Assert.assertNotNull(date)
11 | end
12 |
13 | java_annotation 'org.jbehave.core.annotations.When("$days days pass")'
14 | java_signature 'void whenDaysPass(int)'
15 | def daysPass(days)
16 | org.junit.Assert.assertNotNull(days)
17 | end
18 |
19 | java_annotation 'org.jbehave.core.annotations.Then("the date is $date")'
20 | java_signature 'void thenTheDate(java.util.Date)'
21 | def theDate(date)
22 | org.junit.Assert.assertNotNull(date)
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/examples/meta/src/main/java/org/jbehave/examples/core/meta/StepsScanner.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.meta;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.ComponentScan;
5 | import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
6 |
7 | @ComponentScan({ "org.jbehave.examples.core.meta.steps" })
8 | public class StepsScanner {
9 |
10 | @Bean
11 | public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
12 | return new PropertySourcesPlaceholderConfigurer();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/examples/meta/src/main/java/org/jbehave/examples/core/meta/steps.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/meta/src/main/java/org/jbehave/examples/core/meta/steps/InputSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.meta.steps;
2 |
3 | import org.jbehave.core.annotations.Given;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Component
7 | public class InputSteps {
8 |
9 | @Given("some input $input")
10 | public void someInput(final String input) {
11 | System.out.println(input);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/examples/meta/src/main/java/org/jbehave/examples/core/meta/stories/meta_by_row.story:
--------------------------------------------------------------------------------
1 | Scenario: a scenario with examples
2 |
3 | Given some input
4 |
5 | Examples:
6 | {metaByRow=true}
7 | |Meta: |param |
8 | |@regression|hi there!|
9 | |@regression|hello |
10 | |@smoke |bye bye |
11 |
--------------------------------------------------------------------------------
/examples/needle/src/main/java/org/jbehave/examples/core/needle/steps/NeedleTraderSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.needle.steps;
2 |
3 | import javax.inject.Inject;
4 |
5 | import org.jbehave.examples.core.service.TradingService;
6 | import org.jbehave.examples.core.steps.TraderSteps;
7 |
8 | /**
9 | * POJO annotated to allow Needle injection.
10 | */
11 | public class NeedleTraderSteps extends TraderSteps {
12 |
13 | @Inject
14 | public NeedleTraderSteps(final TradingService service) {
15 | super(service);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/examples/needle/src/test/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | appender.console.type = Console
2 | appender.console.name = STDOUT
3 | appender.console.layout.type = PatternLayout
4 | appender.console.layout.pattern = %d{HH:mm:ss,SSS} %-5p [%t] %c{3} %3x - %m%n
5 |
6 | rootLogger.level = DEBUG
7 | rootLogger.appenderRefs = console
8 | rootLogger.appenderRef.console.ref = STDOUT
9 |
10 | # package specific
11 | logger.freemarker.name = freemarker.cache
12 | logger.freemarker.level = ERROR
13 |
14 | logger.needle.name = org.needle4j
15 | logger.needle.level = ERROR
16 |
--------------------------------------------------------------------------------
/examples/performance/src/main/java/org/jbehave/examples/performance/stories/generate.story:
--------------------------------------------------------------------------------
1 | When a scenario is generated to parsing.story with a tabular argument of 2000 lines and an examples table of 20 lines
2 |
3 |
--------------------------------------------------------------------------------
/examples/rest/README.md:
--------------------------------------------------------------------------------
1 | The REST example requires an XWiki instance.
2 |
3 | Download it from http://xwiki.org and setup:
4 |
5 | - User with username/password: jbehave/jbehave
6 |
7 | REST Root URI available in Main space: http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages
8 |
9 | To use Maven plugin, see script rest.sh.
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/rest/rest.sh:
--------------------------------------------------------------------------------
1 | ACTION=$1
2 |
3 | if [ "$ACTION" == "" ] ; then
4 | echo "usage: rest.sh [import|export]"
5 | exit;
6 | fi
7 |
8 | PLUGIN="org.jbehave:jbehave-rest:5.1-SNAPSHOT"
9 | PARAMS="-Djbehave.rest.rootURI=http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages -Djbehave.rest.username=jbehave -Djbehave.rest.password=jbehave"
10 |
11 | if [ "$ACTION" == "export" ] ; then
12 | mvn $PLUGIN:export-from-filesystem $PARAMS -Djbehave.rest.resourcesSyntax=jbehave/3.0
13 | else
14 | mvn $PLUGIN:import-to-filesystem $PARAMS
15 | fi
16 |
--------------------------------------------------------------------------------
/examples/rest/src/main/java/org/jbehave/examples/core/rest/stories/export.story:
--------------------------------------------------------------------------------
1 | Scenario: Stories are exported to REST provider
2 |
3 | Given REST provider is XWiki
4 | When stories in src/main/resources/stories are exported to http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/rest/src/main/java/org/jbehave/examples/core/rest/stories/index.story:
--------------------------------------------------------------------------------
1 | Scenario: Story index is retrieved from REST provider. Stories are loaded and uploaded.
2 |
3 | Given REST provider is XWiki
4 | When index is retrieved from http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages
5 | Then the index is not empty
6 | When story first text contains 'first'
7 | When story second text contains 'second'
8 | When story first is uploaded appending 'a modification'
9 | When story first text contains 'a modification'
10 |
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/domain/first.story:
--------------------------------------------------------------------------------
1 | A first domain story
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/domain/second.story:
--------------------------------------------------------------------------------
1 | A second domain story
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/domain/subdomain/third.story:
--------------------------------------------------------------------------------
1 | A third subdomain story
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/main.stories/a_story.story:
--------------------------------------------------------------------------------
1 | another_story
2 |
3 | Narrative:
4 |
5 | .... a modification
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/main.stories/another_story.story:
--------------------------------------------------------------------------------
1 | another_story
2 |
3 | Narrative:
4 |
5 | ....
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/main.webhome/welcome.story:
--------------------------------------------------------------------------------
1 | It's an easy-to-edit website that will help you work better together. This Wiki is made of //pages// sorted by //spaces//. You're currently in the **Main** space, looking at its home page (**WebHome**).
2 |
3 | Learn how to use XWiki with the {{velocity}}[[Getting Started Guide>>http://enterprise.xwiki.org/xwiki/bin/view/GettingStarted/WebHome?version=$xwiki.version]]{{/velocity}}.
4 |
5 | {{velocity}}
6 | #if($hasEdit)You can then use the [[Sandbox space>>Sandbox.WebHome]] to try out your wiki's features.#end
7 | {{/velocity}}
8 |
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/parent_story.story:
--------------------------------------------------------------------------------
1 | The stories containers
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/some_story.story:
--------------------------------------------------------------------------------
1 | Narrative
--------------------------------------------------------------------------------
/examples/rest/src/main/resources/stories/webhome.story:
--------------------------------------------------------------------------------
1 | {{include document="Dashboard.WebHome" context="new"/}}
--------------------------------------------------------------------------------
/examples/scala/src/main/java/org/jbehave/examples/scala/stories/using_scala.story:
--------------------------------------------------------------------------------
1 | Scenario: We want to show how steps can be implemented in a class written in Scala
2 |
3 | Given a date of 10/16/2010
4 | When 2 days pass
5 | Then the date is 10/18/2010
6 |
--------------------------------------------------------------------------------
/examples/scala/src/main/scala/ScalaSteps.scala:
--------------------------------------------------------------------------------
1 | class ScalaSteps {
2 |
3 | @org.jbehave.core.annotations.Given("a date of $date")
4 | def date(date: java.util.Date) {
5 | org.junit.Assert.assertNotNull(date)
6 | }
7 |
8 | @org.jbehave.core.annotations.When("$days days pass")
9 | def daysPass(days: Int) {
10 | org.junit.Assert.assertNotNull(days)
11 | }
12 |
13 | @org.jbehave.core.annotations.Then("the date is $date")
14 | def theDate(date: java.util.Date) {
15 | org.junit.Assert.assertNotNull(date)
16 | }
17 |
18 | override def toString(): String = "ScalaSteps";
19 |
20 | }
--------------------------------------------------------------------------------
/examples/spring-security/src/main/java/org/jbehave/example/spring/security/dao/OrganizationDao.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.example.spring.security.dao;
2 |
3 | import org.jbehave.example.spring.security.domain.Organization;
4 |
5 | public interface OrganizationDao {
6 |
7 | public Organization load(Long id);
8 |
9 | public Organization persist(Organization organization);
10 |
11 | public Organization findByName(String orgName);
12 | }
13 |
--------------------------------------------------------------------------------
/examples/spring-security/src/main/java/org/jbehave/example/spring/security/dao/UserDao.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.example.spring.security.dao;
2 |
3 | import org.jbehave.example.spring.security.domain.User;
4 |
5 | public interface UserDao {
6 |
7 | public User load(Long id);
8 |
9 | public User persist(User user);
10 |
11 | public User findUserByOrganizationAndUsername(Long organizationId, String username);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/examples/spring-security/src/main/java/org/jbehave/example/spring/security/util/DateUtils.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.example.spring.security.util;
2 |
3 | import java.util.Date;
4 |
5 | public abstract class DateUtils {
6 |
7 | public static long getElapsedDays(Date earlyDate, Date laterDate) {
8 | long durationMillis = laterDate.getTime() - earlyDate.getTime();
9 | return durationMillis / (1000 * 60 * 60 * 24);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/spring-security/src/main/java/org/jbehave/example/spring/security/util/SecurityUtils.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.example.spring.security.util;
2 |
3 | import org.springframework.security.crypto.factory.PasswordEncoderFactories;
4 | import org.springframework.security.crypto.password.PasswordEncoder;
5 |
6 | public abstract class SecurityUtils {
7 | private static final PasswordEncoder PASSWORD_ENCODER = PasswordEncoderFactories.createDelegatingPasswordEncoder();
8 |
9 | public static String encodePassword(String passwordCleartext) {
10 | return PASSWORD_ENCODER.encode(passwordCleartext);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/examples/spring-security/src/main/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | appender.console.type = Console
2 | appender.console.name = STDOUT
3 | appender.console.layout.type = PatternLayout
4 | appender.console.layout.pattern = %-4r [%t] %-5p %c %x - %m%n
5 |
6 | rootLogger.level = ERROR
7 | rootLogger.appenderRefs = console
8 | rootLogger.appenderRef.console.ref = STDOUT
9 |
--------------------------------------------------------------------------------
/examples/spring/src/main/java/org/jbehave/examples/core/spring/CoreStoriesUsingSpringWithAnnotationConfiguration.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.spring;
2 |
3 | import org.jbehave.core.steps.spring.SpringApplicationContextFactory;
4 | import org.springframework.context.ApplicationContext;
5 |
6 | /**
7 | * Using Spring's annotation configuration
8 | */
9 | public class CoreStoriesUsingSpringWithAnnotationConfiguration extends CoreStoriesUsingSpring {
10 |
11 | @Override
12 | protected ApplicationContext createContext() {
13 | return new SpringApplicationContextFactory("org.jbehave.examples.core.spring.SpringAnnotationConfiguration")
14 | .createApplicationContext();
15 | }
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/examples/threads/README.md:
--------------------------------------------------------------------------------
1 | Have a look ath the element within the pom.xml of this example.
2 |
3 | By default, two threads are going to execute stories. There are three stories, so two will go in parallel, followed by the third on its own.
4 |
5 | If you do mvn install -Dthreads=1 you're overiding the setting of the pom file.
--------------------------------------------------------------------------------
/examples/threads/src/main/java/org/jbehave/examples/threads/stories/a_failed.story:
--------------------------------------------------------------------------------
1 | Scenario: A failing scenario
2 |
3 | Meta:
4 |
5 | @outcome failed
6 |
7 | When something bad happens
8 |
--------------------------------------------------------------------------------
/examples/threads/src/main/java/org/jbehave/examples/threads/stories/a_long.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme Twain
4 | @actor Huck
5 |
6 | Scenario: Huck counts
7 |
8 | When Huck counts to 5 Mississippi
9 |
--------------------------------------------------------------------------------
/examples/threads/src/main/java/org/jbehave/examples/threads/stories/another_long.story:
--------------------------------------------------------------------------------
1 | Meta:
2 |
3 | @theme Twain
4 | @actor Tom
5 |
6 | Scenario: Tom counts
7 |
8 | When Tom counts to 10 Mississippi
9 |
--------------------------------------------------------------------------------
/examples/upload-reports.sh:
--------------------------------------------------------------------------------
1 |
2 | EXAMPLE=$1
3 |
4 | if [ "$EXAMPLE" == "" ]; then
5 | echo "usage: upload-reports.sh "
6 | exit;
7 | fi
8 |
9 | cd target
10 |
11 | cp -r jbehave-reports/view $EXAMPLE
12 |
13 | zip -r $EXAMPLE.zip $EXAMPLE
14 |
15 | scp $EXAMPLE.zip jbehave.org:
16 |
17 | EXAMPLES="/var/www/jbehave.org/reference/examples"
18 |
19 | ssh jbehave.org "rm -r $EXAMPLE; unzip -uo $EXAMPLE.zip; mkdir -p $EXAMPLES; rm -r $EXAMPLES/$EXAMPLE; mv -f $EXAMPLE $EXAMPLES"
20 |
--------------------------------------------------------------------------------
/examples/urls/src/main/java/org/jbehave/examples/core/urls/URLCoreEmbedder.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.urls;
2 |
3 | import org.jbehave.core.configuration.Configuration;
4 | import org.jbehave.core.io.LoadFromURL;
5 | import org.jbehave.examples.core.CoreStoriesEmbedders.CoreEmbedder;
6 |
7 | /**
8 | * Specifies the Embedder for the core example, using URL story loading. It
9 | * extends CoreEmbedder simply for convenience, in order to avoid
10 | * duplicating common configuration.
11 | */
12 | public class URLCoreEmbedder extends CoreEmbedder {
13 |
14 | @Override
15 | public Configuration configuration() {
16 | return super.configuration().useStoryLoader(new LoadFromURL());
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/examples/weld/src/main/java/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/weld/src/main/java/org/jbehave/examples/core/weld/WeldCoreSteps.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.examples.core.weld;
2 |
3 | import javax.inject.Inject;
4 | import javax.inject.Singleton;
5 |
6 | import org.jbehave.core.annotations.weld.WeldStep;
7 | import org.jbehave.examples.core.service.TradingService;
8 | import org.jbehave.examples.core.steps.TraderSteps;
9 |
10 |
11 | /**
12 | * POJO annotated to allow Weld injection.
13 | */
14 | @WeldStep
15 | @Singleton
16 | public class WeldCoreSteps extends TraderSteps {
17 |
18 | @Inject
19 | public WeldCoreSteps(TradingService service) {
20 | super(service);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/jbehave-core/src/main/java/org/jbehave/core/InjectableEmbedder.java:
--------------------------------------------------------------------------------
1 | package org.jbehave.core;
2 |
3 | import org.jbehave.core.embedder.Embedder;
4 |
5 | /**
6 | *
7 | * Abstract implementation of {@link Embeddable} which allows to inject
8 | * the {@link Embedder} used to run the story or stories.
9 | *