SlideShare a Scribd company logo
1 of 32
Download to read offline
@cucumberbdd#Devoxx @citrus_test
Behavior Driven
Integration
with Cucumber and Citrus
Christoph Deppisch
ConSol Software GmbH
@cucumberbdd#Devoxx @citrus_test
https://cucumber.io
https://citrusframework.org
@cucumberbdd#Devoxx @citrus_test
Behavior Driven
Development
@cucumberbdd#Devoxx @citrus_test
Communication
@cucumberbdd#Devoxx @citrus_test
=
DOMAIN EXPERTS DEVELOPMENT
@cucumberbdd#Devoxx @citrus_test
Explaining the
behavior
@cucumberbdd#Devoxx @citrus_test
Concrete
Examples
@cucumberbdd#Devoxx @citrus_test
Gherkin
Given a certain context
When some event happens
Then an outcome should occur
@cucumberbdd#Devoxx @citrus_test
Demo application
@cucumberbdd#Devoxx @citrus_test
Feature: Create voting



As a user I want to create new votings. Each voting is given default vote 

options.



Scenario: Default voting options

Given voting title "Do you like Devoxx?"

When I create new voting

Then voting should have 2 options

And voting should have option "yes"

And voting should have option "no"
And voting title should be "Do you like Devoxx?“
Feature specification
@cucumberbdd#Devoxx @citrus_test
Feature: Create voting



As a user I want to create new votings. Each voting is given default vote 

options. The user should be able to set custom vote options.



Scenario: Default voting options

Given voting title "Do you like Devoxx?"

When I create new voting

Then voting should have 2 options

And voting should have option "yes"

And voting should have option "no"
And voting title should be "Do you like Devoxx?"



Scenario: Custom voting options

When I create new voting "What type of Devoxx ticket do you have?"

And voting options are "University:Conference:Combi"

Then voting title should be "What type of Devoxx ticket do you have?"

And voting should have options

| University |

| Conference |

| Combi |
Feature specification
@cucumberbdd#Devoxx @citrus_test
@cucumberbdd#Devoxx @citrus_test
@RunWith(Cucumber.class)

public class VotingFeatureTest {

}
JUnit Cucumber test
voting-close.feature
voting-create.feature
voting-results.feature
public class VotingSteps {
@Given("^New default voting$")
public void defaultVoting() { ... }
@When("^I create new voting "(.+)"$")
public void createVotingWithTitle(String title) { ... }
@Then("^voting should have (d+) options$")
public void votingShouldHaveOptions(int optionCount) { ... } 

}
@cucumberbdd#Devoxx @citrus_test
@When("^I create new voting "(.+)"$")

public void createVotingWithTitle(String title) {

votingId = UUID.randomUUID();

Voting voting = new Voting(votingId, title);

votingService.add(voting);

}
Step definitions
@Then("^voting should have (d+) options$")

public void votingShouldHaveOptions(int optionCount) {

Assert.assertEquals(optionCount,

votingService.get(votingId).getOptions().size());

}
When I create new voting "What type of Devoxx ticket do you have?“
Then voting should have 3 options
@cucumberbdd#Devoxx @citrus_test
@Then("^(?:the )?voting should have options$")

public void votingShouldHaveOptions(DataTable dataTable) {

List<String> options = dataTable.asList(String.class);



votingShouldHaveOptions(options.size());



for(String option : options) {

votingShouldHaveOption(option);

}

}
Data tables
Then voting should have options

| University |

| Conference |

| Combi |
@cucumberbdd#Devoxx @citrus_test
Demo
@cucumberbdd#Devoxx @citrus_test
Feature: Show voting results



As a user I want to vote for an option. All voting results are stored

and the user should be able to get top vote option for each voting.



Background:

Given I create new voting "Do you like Devoxx?"

And voting options are "yes:no"



Scenario: Initial vote results

Then votes of option "yes" should be 0

And votes of option "no" should be 0



Scenario: Get vote results

When I vote for "yes"

Then votes of option "yes" should be 1

And votes of option "no" should be 0

And top vote should be "yes"
Background
@cucumberbdd#Devoxx @citrus_test
Feature: Show voting results



As a user I want to vote for an option. All voting results are stored

and the user should be able to get top vote option for each voting.



Scenario Outline: Get vote results
Given I create new voting "<title>"

And voting options are "yes:no"

When I vote for "yes" <yes_votes> times
And I vote for "no" <no_votes> times

Then votes of option "yes" should be <yes_votes>

And votes of option "no" should be <no_votes>

And top vote should be "<top_vote>"
Examples:

| title | yes_votes | no_votes | top_vote |

| Did you enjoy the salad? | 12 | 5 | yes |

| Did you enjoy the crab sandwich? | 1 | 25 | no |
Scenario Outline
@cucumberbdd#Devoxx @citrus_test
@cucumberbdd#Devoxx @citrus_test
Messaging
Integration
@cucumberbdd#Devoxx @citrus_test
Client VotingApp
Http REST
JMS
Reporting
MailServer
JMS
SMTP
@cucumberbdd#Devoxx @citrus_test
VotingApp
Http REST
JMS
JMS
SMTP
@cucumberbdd#Devoxx @citrus_test
cucumber.api.java.ObjectFactory=cucumber.runtime.java.CitrusObjectFactory
Citrus & Cucumber
@RunWith(Cucumber.class)

public class VotingRestFeatureIT {

}
cucumber.properties
@cucumberbdd#Devoxx @citrus_test
Feature: Voting Http REST API



Background:

Given Voting list is empty

And New voting "Do you like Belgian beer?"

And voting options are "yes:no"



Scenario: Top vote

When client creates the voting

And client votes for "no"

Then votes should be

| yes | 0 |

| no | 1 |

And top vote should be "no"



Scenario: Close voting

Given reporting is enabled

When client creates the voting

And client votes for "yes" 3 times

And client votes for "no" 2 times

And client closes the voting

Then participants should receive reporting mail

"""

Dear participants,



the voting '${title}' came to an end.



The top answer is 'yes'!



Have a nice day!

Your Voting-App Team

"""
Messaging feature
@cucumberbdd#Devoxx @citrus_test
public class VotingRestSteps {



@CitrusEndpoint

private HttpClient votingClient;
@CitrusEndpoint

private MailServer mailServer;


@CitrusResource

private TestRunner runner;



@Given("^Voting list is empty$")

public void clear() {

runner.http(action -> action.client(votingClient)

.send()

.delete("/voting"));



runner.http(action -> action.client(votingClient)

.receive()

.response(HttpStatus.OK));

}
}
Endpoint Injection
@cucumberbdd#Devoxx @citrus_test
@Configuration

public class CitrusEndpointConfig {



@Bean

public HttpClient votingClient() {

return CitrusEndpoints.http()

.client()

.requestUrl("http://localhost:8080/rest/services")

.build();

}



@Bean

public MailServer mailServer() {

return CitrusEndpoints.mail()

.server()

.port(2222)

.autoStart(true)

.autoAccept(true)

.build();

}

}
Endpoint Configuration
@cucumberbdd#Devoxx @citrus_test
Citrus endpoints
Component Description
citrus-http Http REST client and server
citrus-jms JMS queue or topic destination
citrus-ws SOAP client and server
citrus-mail SMTP mail client and server
citrus-docker Docker container management
citrus-camel Apache Camel endpoint
citrus-selenium Selenium browser endpoint
citrus-vertx Vert.x endpoint
citrus-kubernetes Kubernetes client
…
@cucumberbdd#Devoxx @citrus_test
@Then("^participants should receive reporting mail$")

public void shouldReceiveReportingMail(String mailBody) {


runner.receive(action -> action.endpoint(mailServer)

.message(MailMessage.request()

.from("voting@example.org")

.to("participants@example.org")

.subject("Voting results")

.body(mailBody, "text/plain; charset=us-ascii")));
runner.send(action -> action.endpoint(mailServer)

.message(MailMessage.response(250, „OK"));


}
Mail SMTP messaging
@cucumberbdd#Devoxx @citrus_test
@Bean

public JmsEndpoint reportingEndpoint() {

return CitrusEndpoints.jms()

.asynchronous()

.connectionFactory(connectionFactory())

.destination("jms.voting.report")

.build();

}
JMS messaging
@CitrusEndpoint(name = "reportingEndpoint")

private JmsEndpoint reportingEndpoint;
@Then("^reporting should receive vote results$")

public void shouldReceiveReport(DataTable dataTable) {

runner.createVariable("results", buildOptionsAsJsonArray(dataTable));



runner.receive(action -> action.endpoint(reportingEndpoint)

.messageType(MessageType.JSON)

.payload("{"id":"${id}","title":"${title}","options":${results}}"));

}
@cucumberbdd#Devoxx @citrus_test
Demo
@cucumberbdd#Devoxx @citrus_test
Reading & information
https://cucumber.io
https://citrusframework.org
Demo Sources
https://github.com/christophd/citrus-demo-devoxx-be
Citrus Cucumber Extension
https://citrusframework.org/reference/html/#cucumber
@cucumberbdd#Devoxx @citrus_test
ThankYou!

More Related Content

Similar to Behavior driven integration with Cucumber & Citrus

How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)David Giard
 
Behaviour-Driven Development for Conversational Applications
Behaviour-Driven Development for Conversational ApplicationsBehaviour-Driven Development for Conversational Applications
Behaviour-Driven Development for Conversational ApplicationsFlorian Georg
 
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable ServicesJeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable Servicesit-people
 
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016Phil Leggetter
 
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...HostedbyConfluent
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimMir Nazim
 
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...Docker, Inc.
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Continuous Integration and Code Coverage in Xcode
Continuous Integration and Code Coverage in XcodeContinuous Integration and Code Coverage in Xcode
Continuous Integration and Code Coverage in XcodeHiep Luong
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava SchmidtJavaDayUA
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...GeeksLab Odessa
 
Laravel and Django and Rails, Oh My!
Laravel and Django and Rails, Oh My!Laravel and Django and Rails, Oh My!
Laravel and Django and Rails, Oh My!Chris Roberts
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRodrigo Urubatan
 
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance
 
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance
 

Similar to Behavior driven integration with Cucumber & Citrus (20)

SOLID Ruby, SOLID Rails
SOLID Ruby, SOLID RailsSOLID Ruby, SOLID Rails
SOLID Ruby, SOLID Rails
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
 
Behaviour-Driven Development for Conversational Applications
Behaviour-Driven Development for Conversational ApplicationsBehaviour-Driven Development for Conversational Applications
Behaviour-Driven Development for Conversational Applications
 
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable ServicesJeff Lindsay: Building Public Infrastructure with Autosustainable Services
Jeff Lindsay: Building Public Infrastructure with Autosustainable Services
 
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016
Real-Time Web Apps & .NET. What Are Your Options? NDC Oslo 2016
 
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
You Put *What* in Your Stream?! Patterns and Practices for Event Design with ...
 
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir NazimDjango Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
Django Introduction Osscamp Delhi September 08 09 2007 Mir Nazim
 
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...
Learning the Alphabet: A/B, CD and [E-Z] in the Docker Datacenter by Brett Ti...
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Continuous Integration and Code Coverage in Xcode
Continuous Integration and Code Coverage in XcodeContinuous Integration and Code Coverage in Xcode
Continuous Integration and Code Coverage in Xcode
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava Schmidt
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
 
XP through TDD
XP through TDDXP through TDD
XP through TDD
 
Workshop – UI audit of Mall.cz – May 2019, Brno
Workshop – UI audit of Mall.cz – May 2019, BrnoWorkshop – UI audit of Mall.cz – May 2019, Brno
Workshop – UI audit of Mall.cz – May 2019, Brno
 
Laravel and Django and Rails, Oh My!
Laravel and Django and Rails, Oh My!Laravel and Django and Rails, Oh My!
Laravel and Django and Rails, Oh My!
 
Cucumber Basics.pdf
Cucumber Basics.pdfCucumber Basics.pdf
Cucumber Basics.pdf
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
 
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
 
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDETDevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
 

Recently uploaded

History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathphntsoaki
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESfuthumetsaneliswa
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.thamaeteboho94
 
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiCall Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiPriya Reddy
 
Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20rejz122017
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityHung Le
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...ZurliaSoop
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxthusosetemere
 
Lions New Portal from Narsimha Raju Dichpally 320D.pptx
Lions New Portal from Narsimha Raju Dichpally 320D.pptxLions New Portal from Narsimha Raju Dichpally 320D.pptx
Lions New Portal from Narsimha Raju Dichpally 320D.pptxlionnarsimharajumjf
 

Recently uploaded (20)

History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth deathHistory of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth death
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINESBIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
 
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.Introduction to Artificial intelligence.
Introduction to Artificial intelligence.
 
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. MumbaiCall Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
Call Girls Near The Byke Suraj Plaza Mumbai »¡¡ 07506202331¡¡« R.K. Mumbai
 
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait Cityin kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
 
Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven CuriosityUnlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
Jual obat aborsi Jakarta 085657271886 Cytote pil telat bulan penggugur kandun...
 
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptxBEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Lions New Portal from Narsimha Raju Dichpally 320D.pptx
Lions New Portal from Narsimha Raju Dichpally 320D.pptxLions New Portal from Narsimha Raju Dichpally 320D.pptx
Lions New Portal from Narsimha Raju Dichpally 320D.pptx
 

Behavior driven integration with Cucumber & Citrus

  • 1. @cucumberbdd#Devoxx @citrus_test Behavior Driven Integration with Cucumber and Citrus Christoph Deppisch ConSol Software GmbH
  • 8. @cucumberbdd#Devoxx @citrus_test Gherkin Given a certain context When some event happens Then an outcome should occur
  • 10. @cucumberbdd#Devoxx @citrus_test Feature: Create voting
 
 As a user I want to create new votings. Each voting is given default vote 
 options.
 
 Scenario: Default voting options
 Given voting title "Do you like Devoxx?"
 When I create new voting
 Then voting should have 2 options
 And voting should have option "yes"
 And voting should have option "no" And voting title should be "Do you like Devoxx?“ Feature specification
  • 11. @cucumberbdd#Devoxx @citrus_test Feature: Create voting
 
 As a user I want to create new votings. Each voting is given default vote 
 options. The user should be able to set custom vote options.
 
 Scenario: Default voting options
 Given voting title "Do you like Devoxx?"
 When I create new voting
 Then voting should have 2 options
 And voting should have option "yes"
 And voting should have option "no" And voting title should be "Do you like Devoxx?"
 
 Scenario: Custom voting options
 When I create new voting "What type of Devoxx ticket do you have?"
 And voting options are "University:Conference:Combi"
 Then voting title should be "What type of Devoxx ticket do you have?"
 And voting should have options
 | University |
 | Conference |
 | Combi | Feature specification
  • 13. @cucumberbdd#Devoxx @citrus_test @RunWith(Cucumber.class)
 public class VotingFeatureTest {
 } JUnit Cucumber test voting-close.feature voting-create.feature voting-results.feature public class VotingSteps { @Given("^New default voting$") public void defaultVoting() { ... } @When("^I create new voting "(.+)"$") public void createVotingWithTitle(String title) { ... } @Then("^voting should have (d+) options$") public void votingShouldHaveOptions(int optionCount) { ... } 
 }
  • 14. @cucumberbdd#Devoxx @citrus_test @When("^I create new voting "(.+)"$")
 public void createVotingWithTitle(String title) {
 votingId = UUID.randomUUID();
 Voting voting = new Voting(votingId, title);
 votingService.add(voting);
 } Step definitions @Then("^voting should have (d+) options$")
 public void votingShouldHaveOptions(int optionCount) {
 Assert.assertEquals(optionCount,
 votingService.get(votingId).getOptions().size());
 } When I create new voting "What type of Devoxx ticket do you have?“ Then voting should have 3 options
  • 15. @cucumberbdd#Devoxx @citrus_test @Then("^(?:the )?voting should have options$")
 public void votingShouldHaveOptions(DataTable dataTable) {
 List<String> options = dataTable.asList(String.class);
 
 votingShouldHaveOptions(options.size());
 
 for(String option : options) {
 votingShouldHaveOption(option);
 }
 } Data tables Then voting should have options
 | University |
 | Conference |
 | Combi |
  • 17. @cucumberbdd#Devoxx @citrus_test Feature: Show voting results
 
 As a user I want to vote for an option. All voting results are stored
 and the user should be able to get top vote option for each voting.
 
 Background:
 Given I create new voting "Do you like Devoxx?"
 And voting options are "yes:no"
 
 Scenario: Initial vote results
 Then votes of option "yes" should be 0
 And votes of option "no" should be 0
 
 Scenario: Get vote results
 When I vote for "yes"
 Then votes of option "yes" should be 1
 And votes of option "no" should be 0
 And top vote should be "yes" Background
  • 18. @cucumberbdd#Devoxx @citrus_test Feature: Show voting results
 
 As a user I want to vote for an option. All voting results are stored
 and the user should be able to get top vote option for each voting.
 
 Scenario Outline: Get vote results Given I create new voting "<title>"
 And voting options are "yes:no"
 When I vote for "yes" <yes_votes> times And I vote for "no" <no_votes> times
 Then votes of option "yes" should be <yes_votes>
 And votes of option "no" should be <no_votes>
 And top vote should be "<top_vote>" Examples:
 | title | yes_votes | no_votes | top_vote |
 | Did you enjoy the salad? | 12 | 5 | yes |
 | Did you enjoy the crab sandwich? | 1 | 25 | no | Scenario Outline
  • 21. @cucumberbdd#Devoxx @citrus_test Client VotingApp Http REST JMS Reporting MailServer JMS SMTP
  • 23. @cucumberbdd#Devoxx @citrus_test cucumber.api.java.ObjectFactory=cucumber.runtime.java.CitrusObjectFactory Citrus & Cucumber @RunWith(Cucumber.class)
 public class VotingRestFeatureIT {
 } cucumber.properties
  • 24. @cucumberbdd#Devoxx @citrus_test Feature: Voting Http REST API
 
 Background:
 Given Voting list is empty
 And New voting "Do you like Belgian beer?"
 And voting options are "yes:no"
 
 Scenario: Top vote
 When client creates the voting
 And client votes for "no"
 Then votes should be
 | yes | 0 |
 | no | 1 |
 And top vote should be "no"
 
 Scenario: Close voting
 Given reporting is enabled
 When client creates the voting
 And client votes for "yes" 3 times
 And client votes for "no" 2 times
 And client closes the voting
 Then participants should receive reporting mail
 """
 Dear participants,
 
 the voting '${title}' came to an end.
 
 The top answer is 'yes'!
 
 Have a nice day!
 Your Voting-App Team
 """ Messaging feature
  • 25. @cucumberbdd#Devoxx @citrus_test public class VotingRestSteps {
 
 @CitrusEndpoint
 private HttpClient votingClient; @CitrusEndpoint
 private MailServer mailServer; 
 @CitrusResource
 private TestRunner runner;
 
 @Given("^Voting list is empty$")
 public void clear() {
 runner.http(action -> action.client(votingClient)
 .send()
 .delete("/voting"));
 
 runner.http(action -> action.client(votingClient)
 .receive()
 .response(HttpStatus.OK));
 } } Endpoint Injection
  • 26. @cucumberbdd#Devoxx @citrus_test @Configuration
 public class CitrusEndpointConfig {
 
 @Bean
 public HttpClient votingClient() {
 return CitrusEndpoints.http()
 .client()
 .requestUrl("http://localhost:8080/rest/services")
 .build();
 }
 
 @Bean
 public MailServer mailServer() {
 return CitrusEndpoints.mail()
 .server()
 .port(2222)
 .autoStart(true)
 .autoAccept(true)
 .build();
 }
 } Endpoint Configuration
  • 27. @cucumberbdd#Devoxx @citrus_test Citrus endpoints Component Description citrus-http Http REST client and server citrus-jms JMS queue or topic destination citrus-ws SOAP client and server citrus-mail SMTP mail client and server citrus-docker Docker container management citrus-camel Apache Camel endpoint citrus-selenium Selenium browser endpoint citrus-vertx Vert.x endpoint citrus-kubernetes Kubernetes client …
  • 28. @cucumberbdd#Devoxx @citrus_test @Then("^participants should receive reporting mail$")
 public void shouldReceiveReportingMail(String mailBody) { 
 runner.receive(action -> action.endpoint(mailServer)
 .message(MailMessage.request()
 .from("voting@example.org")
 .to("participants@example.org")
 .subject("Voting results")
 .body(mailBody, "text/plain; charset=us-ascii"))); runner.send(action -> action.endpoint(mailServer)
 .message(MailMessage.response(250, „OK")); 
 } Mail SMTP messaging
  • 29. @cucumberbdd#Devoxx @citrus_test @Bean
 public JmsEndpoint reportingEndpoint() {
 return CitrusEndpoints.jms()
 .asynchronous()
 .connectionFactory(connectionFactory())
 .destination("jms.voting.report")
 .build();
 } JMS messaging @CitrusEndpoint(name = "reportingEndpoint")
 private JmsEndpoint reportingEndpoint; @Then("^reporting should receive vote results$")
 public void shouldReceiveReport(DataTable dataTable) {
 runner.createVariable("results", buildOptionsAsJsonArray(dataTable));
 
 runner.receive(action -> action.endpoint(reportingEndpoint)
 .messageType(MessageType.JSON)
 .payload("{"id":"${id}","title":"${title}","options":${results}}"));
 }
  • 31. @cucumberbdd#Devoxx @citrus_test Reading & information https://cucumber.io https://citrusframework.org Demo Sources https://github.com/christophd/citrus-demo-devoxx-be Citrus Cucumber Extension https://citrusframework.org/reference/html/#cucumber