SlideShare a Scribd company logo
@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

SOLID Ruby, SOLID Rails
SOLID Ruby, SOLID RailsSOLID Ruby, SOLID Rails
SOLID Ruby, SOLID Rails
Jens-Christian Fischer
 
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 Applications
Florian 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 Services
it-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 2016
Phil 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 Nazim
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...
Docker, Inc.
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
davejohnson
 
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
Hiep 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 Schmidt
JavaDayUA
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
Hendrik 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
 
XP through TDD
XP through TDDXP through TDD
XP through TDD
Mauricio Cappella
 
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
Czech Design Systems Community
 
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
 
Cucumber Basics.pdf
Cucumber Basics.pdfCucumber Basics.pdf
Cucumber Basics.pdf
Mithilesh Singh
 
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
Rodrigo 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 SDET
DevLabs 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 SDET
DevLabs 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

Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
kkirkland2
 
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPointMẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
1990 Media
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
SkillCertProExams
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
artemacademy2
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Dutch Power
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
amekonnen
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Rosie Wells
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
OECD Directorate for Financial and Enterprise Affairs
 
Competition and Regulation in Professions and Occupations – ROBSON – June 202...
Competition and Regulation in Professions and Occupations – ROBSON – June 202...Competition and Regulation in Professions and Occupations – ROBSON – June 202...
Competition and Regulation in Professions and Occupations – ROBSON – June 202...
OECD Directorate for Financial and Enterprise Affairs
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Dutch Power
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
Frederic Leger
 
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
OECD Directorate for Financial and Enterprise Affairs
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
Updated diagnosis. Cause and treatment of hypothyroidism
Updated diagnosis. Cause and treatment of hypothyroidismUpdated diagnosis. Cause and treatment of hypothyroidism
Updated diagnosis. Cause and treatment of hypothyroidism
Faculty of Medicine And Health Sciences
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
gharris9
 
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
OECD Directorate for Financial and Enterprise Affairs
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
gpww3sf4
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 

Recently uploaded (20)

Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
 
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPointMẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
Mẫu PPT kế hoạch làm việc sáng tạo cho nửa cuối năm PowerPoint
 
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussionPro-competitive Industrial Policy – OECD – June 2024 OECD discussion
Pro-competitive Industrial Policy – OECD – June 2024 OECD discussion
 
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
 
Carrer goals.pptx and their importance in real life
Carrer goals.pptx  and their importance in real lifeCarrer goals.pptx  and their importance in real life
Carrer goals.pptx and their importance in real life
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
 
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
Artificial Intelligence, Data and Competition – ČORBA – June 2024 OECD discus...
 
Competition and Regulation in Professions and Occupations – ROBSON – June 202...
Competition and Regulation in Professions and Occupations – ROBSON – June 202...Competition and Regulation in Professions and Occupations – ROBSON – June 202...
Competition and Regulation in Professions and Occupations – ROBSON – June 202...
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
 
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
Competition and Regulation in Professions and Occupations – OECD – June 2024 ...
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
Updated diagnosis. Cause and treatment of hypothyroidism
Updated diagnosis. Cause and treatment of hypothyroidismUpdated diagnosis. Cause and treatment of hypothyroidism
Updated diagnosis. Cause and treatment of hypothyroidism
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
 
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussionPro-competitive Industrial Policy – LANE – June 2024 OECD discussion
Pro-competitive Industrial Policy – LANE – June 2024 OECD discussion
 
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
原版制作贝德福特大学毕业证(bedfordhire毕业证)硕士文凭原版一模一样
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
 

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