The sample uses Cucumber behavior driven development (BDD) library. The tests combine BDD feature stories with the famous Gherkin syntax and Citrus integration test capabilities. Read about this feature in reference guide
This sample application shows the usage of both Cucumber and Citrus in combination. Step definitions are able to use CitrusResource annotations for injecting a TestDesigner instance. The test designer is then used in steps to build a Citrus integration test.
We start with a feature test using JUnit and Cucumber runner.
The test feature is described in a story using Gherkin syntax.
Feature: Todo app Scenario: Add todo entry Given Todo list is empty When I add entry "Code something" Then the number of todo entries should be 1 Scenario: Remove todo entry Given Todo list is empty When I add entry "Remove me" Then the number of todo entries should be 1 When I remove entry "Remove me" Then the todo list should be empty
The steps executed are defined in a separate class where a Citrus test designer is used to build integration test logic.
In order to enable Citrus Cucumber support we need to specify a special object factory in cucumber.properties.
The object factory takes care on creating all step definition instances. The object factory is able to inject @CitrusResource annotated fields in step classes.
The usage of this special object factory is mandatory in order to combine Citrus and Cucumber capabilities.
We also have the usual citrus-context.xml Citrus Spring configuration that is automatically loaded within the object factory. So you can define and use Citrus components as usual within your test. In this sample we use a Http client component to call some REST API on the todo-list application.
You can run the sample on your localhost in order to see Citrus in action. Read the instructions how to run the sample.