Spring boot integration test with cucumber and Jenkins pipeline

Here I am sharing how you can integrate cucumber for behavior driven testing with spring boot integration test and how you collect the reports in Jenkins pipeline.

In a sample spring boot app generated from my custom spring boot archetype we will show a small integration test suite with cucumber and spring boot.

Steps to follow are :

1- Add cucumber maven dependencies to your spring boot pom.xml

<!-- Cucumber-->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>${cucumber-version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>${cucumber-version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-spring</artifactId>
    <version>${cucumber-version}</version>
    <scope>test</scope>
</dependency>

2- Define cucumber features in your test resources :

Screen Shot 2017-12-03 at 19.00.06

3- How to define the features implementation to be executed with your spring boot app logic :

the feature description :

the feature implementation :

4- How to execute the integration test :

you need to configure the root executor with Cucumber runner as the following:

and the integration test triggering which will be done via spring boot integration test :

5- how to collect the test reports in Jenkins pipeline :

Complete working sample is here :

GitHub: https://github.com/Romeh/spring-boot-sample-app

References :

  1. Cucumber: https://cucumber.io/
  2. Spring boot : https://projects.spring.io/spring-boot/

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s