SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
Behaviour Driven
Developmentusing Cucumber JVM and Groovy
About Me
Marco Vermeulen
Java Dev for past 10 years
Groovy and Grails for 5
Worked for Shazam, Associated Newspapers, Burberry
Currently: Consulting at Equal Experts
Author of GVM (Groovy enVironment Manager)
Twitter:
http://wiredforcode.com
@marcoVermeulen
About the Talk
BDD in a Nutshell
The Good and Bad of BDD
Cucumber as solution
Mini Cucumber Demo
Grails Cucumber Plugin
Example Application
BDD Defined
Straight from the horse's mouth:
#BDD in a tweet: Using examples at multiple levels to create a
shared understanding and surface uncertainty to deliver
software that matters
9:10 PM ­ 26 May 2013
Dan North 
@tastapod
FollowFollow
95 RETWEETS  54 FAVORITES
   
BDD in a Nutshell
Using Examples
at multiple levels
to create a shared understanding
and surface uncertainty
to deliver software
that matters!
So???Collaborate on a Specification that all understand.
Write in light weight markup called Gherkin.
Make Executable Specifications by parsing the markup.
Watch these new Pending unimplemented tests fail!
Implement the tests, watching them fail.
Write the Implementation, watch it pass!
Bad Wrap
An Orphan
Marketing Hype
ATDD (Acceptance Test Driven Development)
Lost it's Zing!!!
Good Vibrations
TDD Evolved
Inspires Collaboration
Behaviour vs Implementation
Living Documentation
Abundance of Tools
Simples!
Abundance of Tools
JBehave
Concordian
Fitnesse
EasyB
Spock?
Jasmine (for JavaScript)
Cucumber
Cucumber and
Gradle
Cucumber and Gradle
An Anatomy
Dependencies
JUnit Test Runner
Gherkin
Step Definitions
Hooks
Tags
Cucumber Anatomy
Dependencies
build.gradle
repositories {
mavenCentral()
}
dependencies {
groovy 'org.codehaus.groovy:groovy:2.1.5'
testCompile 'junit:junit:4.11'
testCompile 'info.cukes:cucumber-groovy:1.1.1'
testCompile 'info.cukes:cucumber-junit:1.1.1'
}
Cucumber Anatomy
Test Runner
src/test/groovy/RunCukeTests.groovy
import cucumber.api.junit.Cucumber
import org.junit.runner.RunWith
@RunWith(Cucumber)
@Cucumber.Options(
format=["pretty", "html:build/reports/cucumber"],
strict=true,
features=["src/test/cucumber"],
glue=["src/test/cucumber/steps", "src/test/cucumber/support"],
tags=["~@manual", "~@review"]
)
public class RunCukesTest {
//leave me empty!
}
Cucumber Anatomy
Gherkin
src/test/cucumber/adding.feature
Feature: Calculate
Scenario: Add two numbers
Given the input "2+2"
When the calculator is run
Then the output should be "4"
Scenario: Subtract two numbers
Given the input "9-4"
When the calculator is run
Then the output should be "5"
Cucumber Anatomy
Step Definitions
src/test/cucumber/steps/add_steps.groovy
import static cucumber.api.groovy.EN.*
Given(~'^the input "([^"]*)"$') { String input ->
//some groovy code
}
When(~'^the calculator is run$') { ->
//some groovy code
}
Then(~'^the output should be "([^"]*)"$') { String output ->
//some groovy code
}
Cucumber Anatomy
Hooks
src/test/cucumber/support/env.groovy
Before and After each Scenario
import static cucumber.api.groovy.Hooks.*
Before(){
//some groovy code
}
After(){
//some groovy code
}
Mini Demo
Grails Cucumber Plugin
by Martin Hauner
Plugin Portal
https://github.com/hauner/grails-cucumber
Grails Cucumber Plugin
Features
Convention over Configuration
Easy Configuration
No Test Runner
Uses Functional Test phase
Has Friends! (Geb, Spock, Build Test Data, Fixtures)
Command Line integration
Good IDE Support
Under active development
Grails Cucumber
ExampleGVM admin console
Contrived example!!!
Walking skeleton
All moving parts of setup
Grails Cucumber Example
Configuration
grails-app/conf/BuildConfig.groovy
plugins {
...
test ":cucumber:0.8.0"
...
}
Grails Cucumber Example
Configuration
grails-app/conf/CucumberConfig.groovy
Replaces Test Runner .
cucumber {
tags = ["~@manual"]
features = ["test/cucumber"]
strict = true
glue = ["test/cucumber/steps", "test/cucumber/support"]
}
configuration
Grails Cucumber Example
Test Folder Structure
Grails Cucumber Example
Gherkin Feature
test/cucumber/manage_candidates.feature
Feature: Manage Candidates
Scenario: List Candidates
Given the candidate "Grails" exists with default version "2.2.2"
And the candidate "Groovy" exists with default version "2.1.4"
When I visit the Candidate page
Then I see "Grails" listed
And I see "Groovy" listed
Grails Cucumber Example
Step Definitions
test/cucumber/steps/manage_candidates.groovy
Gorm!
Geb!
Given(~'^the candidate "([^"]*)" exists with default version "([^"]*)"$'){ St
def candidate = new Candidate(
name: name,
defaultVersion: defaultVersion
)
assert candidate.save()
}
When(~'^I visit the Candidate page$') { ->
to CandidatePage
at CandidatePage
}
Then(~'^I see "([^"]*)" listed$') { String candidateName ->
assert page.isCandidateInList(candidateName)
}
Grails Cucumber Example
Domain Class
grails-app/domain/../Candidate.groovy
class Candidate {
String name
String defaultVersion
}
Grails Cucumber Example
Geb Configuration
test/functional/GebConfig.groovy
Remember to chromedriver!
Place it in root of project folder.
...or use any selenium driver you like.
import org.openqa.selenium.chrome.ChromeDriver
driver = {
new ChromeDriver()
}
download
Grails Cucumber Example
Geb Page
test/functional/page/CandidatePage.groovy
class CandidatePage extends Page {
static url = "candidate/list"
static at = { title ==~ /Candidate List/ }
static content = {
candidateList { $("div.list table", 0) }
candidate { candidateName ->
module CandidateModule, $("#$candidateName")
}
}
def isCandidateInList(String candidateName){
def candidateRow = candidate(candidateName)
return candidateRow ? true : false
}
}
Grails Cucumber Example
Geb Module
test/functional/modules/CandidatePage.groovy
class CandidateModule extends Module{
static content = {
name { $("#name") }
defaultVersion { $("#default") }
}
}
Grails Cucumber Example
Environment Hooks
test/cucumber/support/env.groovy
Use for any long running fixture
Hooks run before and after each scenario
Like @BeforeClass and @AfterClass in JUnit
Before () {
bindingUpdater = new BindingUpdater (binding, new Browser ())
bindingUpdater.initialize ()
}
After () {
bindingUpdater.remove ()
}
Grails Cucumber Example
Hooks: Clean up GORM
test/cucumber/support/fixture.groovy
GORM's Hibernate session leaks across Scenarios.
Feels sleezy :-P
After () {
def sessionFactory = appCtx.getBean("sessionFactory")
sessionFactory.currentSession.flush()
def dataSource = appCtx.getBean("dataSource")
//clean fixtures
println "Deleting the fixture..."
def db = new Sql(dataSource)
db.execute("DELETE FROM CANDIDATE;")
sessionFactory.currentSession.clear()
}
Grails Cucumber Example
Spock Specification
@TestFor(CandidateController)
@Build([Candidate])
class CandidateControllerSpec extends Specification {
void "should return a list of available candidates"(){
given:
def grails = new Candidate(name:'grails',defaultVersion:'2.2.2').sav
def groovy = new Candidate(name:'groovy',defaultVersion:'2.1.5').sav
when:
def result = controller.list()
then:
result.candidateInstanceList.contains grails
result.candidateInstanceList.contains groovy
}
}
Grails Cucumber Example
Controller
Controller
class CandidateController {
def list(Integer max) {
params.max = Math.min(max ?: 10, 100)
[candidateInstanceList: Candidate.list(params),
candidateInstanceTotal: Candidate.count()]
}
}
Grails Cucumber Example
GSP
<g:each in="${candidateInstanceList}"
status="i" var="candidateInstance">
<tr>
<td id="${candidateInstance.name}">
${fieldValue(bean: candidateInstance, field: "name")}
</td>
<td>
<g:link action="show" id="${candidateInstance.id}">
${fieldValue(bean: candidateInstance, field: "defaultVersion")}
</g:link>
</td>
</tr>
</g:each>
ConclusionBDD helps us Collaborate
BDD helps us make software that Matters!
Cucumber JVM and Gradle play nicely
Grails Cucumber plugin Rocks!
BDD is lots of fun!
Thank You!!!
Q & A

Más contenido relacionado

La actualidad más candente

CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunSQABD
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...Ho Chi Minh City Software Testing Club
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011dimakovalenko
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Storiesrahoulb
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberKMS Technology
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberAsheesh Mehdiratta
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third PluginJustin Ryan
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliRebecca Eloise Hogg
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingDougal Campbell
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react formYao Nien Chung
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsLeticia Rss
 
Capybara testing
Capybara testingCapybara testing
Capybara testingFutureworkz
 
Testing Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and SeleniumTesting Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and SeleniumChris Johnson
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentYao Nien Chung
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFesttomdale
 

La actualidad más candente (20)

CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
 
Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011Selenium and Cucumber Selenium Conf 2011
Selenium and Cucumber Selenium Conf 2011
 
BDD, Behat & Drupal
BDD, Behat & DrupalBDD, Behat & Drupal
BDD, Behat & Drupal
 
RSpec User Stories
RSpec User StoriesRSpec User Stories
RSpec User Stories
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
Writing automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjectsWriting automation tests with python selenium behave pageobjects
Writing automation tests with python selenium behave pageobjects
 
Capybara testing
Capybara testingCapybara testing
Capybara testing
 
Testing Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and SeleniumTesting Any Site With Cucumber and Selenium
Testing Any Site With Cucumber and Selenium
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
Enhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order componentEnhance react app with patterns - part 1: higher order component
Enhance react app with patterns - part 1: higher order component
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 

Similar a greach 2014 marco vermeulen bdd using cucumber jvm and groovy

Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebC4Media
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with GebRichard Paul
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyJames Williams
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingAndres Almiray
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsJames Williams
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric Weimer
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the androidJun Liu
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyAndres Almiray
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for JavaCharles Anderson
 
Use Groovy&Grails in your spring boot projects
Use Groovy&Grails in your spring boot projectsUse Groovy&Grails in your spring boot projects
Use Groovy&Grails in your spring boot projectsParadigma Digital
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StoryKon Soulianidis
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugintobiaspreuss
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App EngineFred Lin
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructureLindsay Holmwood
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 

Similar a greach 2014 marco vermeulen bdd using cucumber jvm and groovy (20)

Test Driven In Groovy
Test Driven In GroovyTest Driven In Groovy
Test Driven In Groovy
 
Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
 
Acceptance testing with Geb
Acceptance testing with GebAcceptance testing with Geb
Acceptance testing with Geb
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
Use Groovy&Grails in your spring boot projects
Use Groovy&Grails in your spring boot projectsUse Groovy&Grails in your spring boot projects
Use Groovy&Grails in your spring boot projects
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Svcc Groovy Testing
Svcc Groovy TestingSvcc Groovy Testing
Svcc Groovy Testing
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugin
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Whats New In Groovy 1.6?
Whats New In Groovy 1.6?Whats New In Groovy 1.6?
Whats New In Groovy 1.6?
 

Último

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 

Último (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 

greach 2014 marco vermeulen bdd using cucumber jvm and groovy

  • 2. About Me Marco Vermeulen Java Dev for past 10 years Groovy and Grails for 5 Worked for Shazam, Associated Newspapers, Burberry Currently: Consulting at Equal Experts Author of GVM (Groovy enVironment Manager) Twitter: http://wiredforcode.com @marcoVermeulen
  • 3. About the Talk BDD in a Nutshell The Good and Bad of BDD Cucumber as solution Mini Cucumber Demo Grails Cucumber Plugin Example Application
  • 4. BDD Defined Straight from the horse's mouth: #BDD in a tweet: Using examples at multiple levels to create a shared understanding and surface uncertainty to deliver software that matters 9:10 PM ­ 26 May 2013 Dan North  @tastapod FollowFollow 95 RETWEETS  54 FAVORITES    
  • 5. BDD in a Nutshell Using Examples at multiple levels to create a shared understanding and surface uncertainty to deliver software that matters!
  • 6. So???Collaborate on a Specification that all understand. Write in light weight markup called Gherkin. Make Executable Specifications by parsing the markup. Watch these new Pending unimplemented tests fail! Implement the tests, watching them fail. Write the Implementation, watch it pass!
  • 7. Bad Wrap An Orphan Marketing Hype ATDD (Acceptance Test Driven Development) Lost it's Zing!!!
  • 8. Good Vibrations TDD Evolved Inspires Collaboration Behaviour vs Implementation Living Documentation Abundance of Tools Simples!
  • 11. Cucumber and Gradle An Anatomy Dependencies JUnit Test Runner Gherkin Step Definitions Hooks Tags
  • 12. Cucumber Anatomy Dependencies build.gradle repositories { mavenCentral() } dependencies { groovy 'org.codehaus.groovy:groovy:2.1.5' testCompile 'junit:junit:4.11' testCompile 'info.cukes:cucumber-groovy:1.1.1' testCompile 'info.cukes:cucumber-junit:1.1.1' }
  • 13. Cucumber Anatomy Test Runner src/test/groovy/RunCukeTests.groovy import cucumber.api.junit.Cucumber import org.junit.runner.RunWith @RunWith(Cucumber) @Cucumber.Options( format=["pretty", "html:build/reports/cucumber"], strict=true, features=["src/test/cucumber"], glue=["src/test/cucumber/steps", "src/test/cucumber/support"], tags=["~@manual", "~@review"] ) public class RunCukesTest { //leave me empty! }
  • 14. Cucumber Anatomy Gherkin src/test/cucumber/adding.feature Feature: Calculate Scenario: Add two numbers Given the input "2+2" When the calculator is run Then the output should be "4" Scenario: Subtract two numbers Given the input "9-4" When the calculator is run Then the output should be "5"
  • 15. Cucumber Anatomy Step Definitions src/test/cucumber/steps/add_steps.groovy import static cucumber.api.groovy.EN.* Given(~'^the input "([^"]*)"$') { String input -> //some groovy code } When(~'^the calculator is run$') { -> //some groovy code } Then(~'^the output should be "([^"]*)"$') { String output -> //some groovy code }
  • 16. Cucumber Anatomy Hooks src/test/cucumber/support/env.groovy Before and After each Scenario import static cucumber.api.groovy.Hooks.* Before(){ //some groovy code } After(){ //some groovy code }
  • 18. Grails Cucumber Plugin by Martin Hauner Plugin Portal https://github.com/hauner/grails-cucumber
  • 19. Grails Cucumber Plugin Features Convention over Configuration Easy Configuration No Test Runner Uses Functional Test phase Has Friends! (Geb, Spock, Build Test Data, Fixtures) Command Line integration Good IDE Support Under active development
  • 20. Grails Cucumber ExampleGVM admin console Contrived example!!! Walking skeleton All moving parts of setup
  • 22. Grails Cucumber Example Configuration grails-app/conf/CucumberConfig.groovy Replaces Test Runner . cucumber { tags = ["~@manual"] features = ["test/cucumber"] strict = true glue = ["test/cucumber/steps", "test/cucumber/support"] } configuration
  • 23. Grails Cucumber Example Test Folder Structure
  • 24.
  • 25. Grails Cucumber Example Gherkin Feature test/cucumber/manage_candidates.feature Feature: Manage Candidates Scenario: List Candidates Given the candidate "Grails" exists with default version "2.2.2" And the candidate "Groovy" exists with default version "2.1.4" When I visit the Candidate page Then I see "Grails" listed And I see "Groovy" listed
  • 26. Grails Cucumber Example Step Definitions test/cucumber/steps/manage_candidates.groovy Gorm! Geb! Given(~'^the candidate "([^"]*)" exists with default version "([^"]*)"$'){ St def candidate = new Candidate( name: name, defaultVersion: defaultVersion ) assert candidate.save() } When(~'^I visit the Candidate page$') { -> to CandidatePage at CandidatePage } Then(~'^I see "([^"]*)" listed$') { String candidateName -> assert page.isCandidateInList(candidateName) }
  • 27. Grails Cucumber Example Domain Class grails-app/domain/../Candidate.groovy class Candidate { String name String defaultVersion }
  • 28. Grails Cucumber Example Geb Configuration test/functional/GebConfig.groovy Remember to chromedriver! Place it in root of project folder. ...or use any selenium driver you like. import org.openqa.selenium.chrome.ChromeDriver driver = { new ChromeDriver() } download
  • 29. Grails Cucumber Example Geb Page test/functional/page/CandidatePage.groovy class CandidatePage extends Page { static url = "candidate/list" static at = { title ==~ /Candidate List/ } static content = { candidateList { $("div.list table", 0) } candidate { candidateName -> module CandidateModule, $("#$candidateName") } } def isCandidateInList(String candidateName){ def candidateRow = candidate(candidateName) return candidateRow ? true : false } }
  • 30. Grails Cucumber Example Geb Module test/functional/modules/CandidatePage.groovy class CandidateModule extends Module{ static content = { name { $("#name") } defaultVersion { $("#default") } } }
  • 31. Grails Cucumber Example Environment Hooks test/cucumber/support/env.groovy Use for any long running fixture Hooks run before and after each scenario Like @BeforeClass and @AfterClass in JUnit Before () { bindingUpdater = new BindingUpdater (binding, new Browser ()) bindingUpdater.initialize () } After () { bindingUpdater.remove () }
  • 32. Grails Cucumber Example Hooks: Clean up GORM test/cucumber/support/fixture.groovy GORM's Hibernate session leaks across Scenarios. Feels sleezy :-P After () { def sessionFactory = appCtx.getBean("sessionFactory") sessionFactory.currentSession.flush() def dataSource = appCtx.getBean("dataSource") //clean fixtures println "Deleting the fixture..." def db = new Sql(dataSource) db.execute("DELETE FROM CANDIDATE;") sessionFactory.currentSession.clear() }
  • 33. Grails Cucumber Example Spock Specification @TestFor(CandidateController) @Build([Candidate]) class CandidateControllerSpec extends Specification { void "should return a list of available candidates"(){ given: def grails = new Candidate(name:'grails',defaultVersion:'2.2.2').sav def groovy = new Candidate(name:'groovy',defaultVersion:'2.1.5').sav when: def result = controller.list() then: result.candidateInstanceList.contains grails result.candidateInstanceList.contains groovy } }
  • 34. Grails Cucumber Example Controller Controller class CandidateController { def list(Integer max) { params.max = Math.min(max ?: 10, 100) [candidateInstanceList: Candidate.list(params), candidateInstanceTotal: Candidate.count()] } }
  • 35. Grails Cucumber Example GSP <g:each in="${candidateInstanceList}" status="i" var="candidateInstance"> <tr> <td id="${candidateInstance.name}"> ${fieldValue(bean: candidateInstance, field: "name")} </td> <td> <g:link action="show" id="${candidateInstance.id}"> ${fieldValue(bean: candidateInstance, field: "defaultVersion")} </g:link> </td> </tr> </g:each>
  • 36. ConclusionBDD helps us Collaborate BDD helps us make software that Matters! Cucumber JVM and Gradle play nicely Grails Cucumber plugin Rocks! BDD is lots of fun!
  • 38. Q & A