Skip to content
Arquillian JBehave TestRunner
Branch: master
Clone or download
Pull request Compare This branch is 14 commits ahead, 1 commit behind arquillian:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Arquillian JBehave TestRunner

What is it?

The Arquillian JBehave TestRunner allows for in-container execution of your JBehave stories. It enables developers to use Arquillian in Behavior-Driven Development allowing for the possibility of using real objects in the execution of stories.


Write your story

Story: Obtain quotes for exchanging currencies

Scenario: Exchange United States Dollars for Japanese Yen

When converting 5 USD to JPY
Then return a quote of 375

Scenario: Exchange United States Dollars for Euros

When converting 130 USD to EUR
Then return a quote of 100

Scenario: Exchange United States Dollars for Pound Sterling

When converting 15 USD to GBP
Then return a quote of 10

Map the Steps to Java

public class ExchangeCurrenciesSteps

   private BigDecimal result;

   private CurrencyExchangeService exchangeService; // Injected, by Arquillian 

   @When("converting $amount $fromCurrencyCode to $toCurrencyCode")
   public void obtainQuote(BigDecimal amount, String fromCurrencyCode, String toCurrencyCode)
      Currency fromCurrency = Currency.getInstance(fromCurrencyCode);
      Currency toCurrency = Currency.getInstance(toCurrencyCode);
      result = exchangeService.getQuote(fromCurrency, amount, toCurrency);

   @Then("return a quote of $quote")
   public void theQuoteShouldBe(String quote)
      Assert.assertEquals(0, result.compareTo(new BigDecimal(quote)));

Configure the Story

public class ExchangeCurrencies extends JUnitStory

    public static WebArchive createDeployment()
        WebArchive archive = ShrinkWrap.create(WebArchive.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
        return archive;

    public ExchangeCurrencies()
          * Configure JBehave to use the Guava SameThreadExecutorService.
          * This enables the ArquillianInstanceStepsFactory to access
          * the ThreadLocal contexts and datastores.

    public Configuration configuration()
        Configuration configuration = new MostUsefulConfiguration()
            .useStoryPathResolver(new UnderscoredCamelCaseResolver())
            .useStoryReporterBuilder(new StoryReporterBuilder()
                .withFormats(CONSOLE, TXT, HTML, XML)
        return configuration;

    public InjectableStepsFactory stepsFactory()
        return new ArquillianInstanceStepsFactory(configuration(), new ExchangeCurrenciesSteps());


Run it

Use Arquillian as usual. The story can be executed from your IDE or from a Maven build.

More Info



You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.