Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baratharivazhagan/cucumber-spring-integration
spring boot application integrated with cucumber and restdocs
https://github.com/baratharivazhagan/cucumber-spring-integration
cucumber gherkin spring-boot spring-mvc
Last synced: 15 days ago
JSON representation
spring boot application integrated with cucumber and restdocs
- Host: GitHub
- URL: https://github.com/baratharivazhagan/cucumber-spring-integration
- Owner: BarathArivazhagan
- Created: 2017-07-30T14:34:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-11T00:45:14.000Z (over 3 years ago)
- Last Synced: 2023-03-07T08:47:45.916Z (over 1 year ago)
- Topics: cucumber, gherkin, spring-boot, spring-mvc
- Language: Java
- Homepage:
- Size: 46.9 KB
- Stars: 5
- Watchers: 1
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cucumber-spring-integration
#### spring boot application integrated with cucumber test casesThis sample demonstrates how to write cucumber test cases to test spring boot application using BDD style.
#### Branch Matrix
Choose the branch before proceeding to further sections.
Branch
Spring Boot Version
Cucumber Version
master
2.3.9.RELEASE
6.10.2
2.3.9
2.3.9.RELEASE
6.10.2
2.1.3
2.1.3.RELEASE
4.2.5
1.0.0
2.0.3.RELEASE
1.2.5
1.5.6
1.5.6.RELEASE
1.2.5
### Development Steps :
step 1 : To start with cucumber :
Add the below dependencies to support Spring with Cucumber:
```
6.10.2
io.cucumber
cucumber-java8
${cucumber.version}
test
io.cucumber
cucumber-java
${cucumber.version}
test
io.cucumber
cucumber-junit
${cucumber.version}
test
io.cucumber
cucumber-spring
${cucumber.version}
test
```step 2: Define the Cucumber Runner Test
```
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features")
public class CucumberRunnerTest {}
```step 3 : Create a feature file and define the BDD steps using gherkin language
Example : Feature describing the scenario of creating a customer with customer details
```
Feature: To save the customer with customer detailsScenario: client makes call to POST /customers to save the customer
Given the customer with customer name "barath" and customer id 7777
When the client calls "/customer" with the given details
Then the client receives status code of 200
And the response contains customer name "barath"
```step 4 : When you run this feature file ```Run as -> Cucumber``` it generates the BDD style of java code.
Using which you can write the service logic.### SaveCustomerStepDefinitionTest.java :
```java@Given("^the customer with customer name \"([^\"]*)\" and customer id (\\d+)$")
public void the_customer_with_customer_name_and_customer_id(String customerName, int customerId) throws Throwable {
}@When("^the client calls \"([^\"]*)\" with the given details$")
public void the_client_calls_customer_save_with_the_given_details(String path) throws Throwable {
}@Then("^the client receives status code of (\\d+)$")
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
}@Then("^the response contains customer name \"([^\"]*)\"$")
public void the_response_contains_customer_name(String customerName) throws Throwable {
}```
step 5 : Run the tests and check the output under output folder
```
mvn test
```