Cucumber
Cucumber
with Cucumber-JVM
Boston Java Meetup, 13/06/2013
Alan Parkinson
@alan_parkinson
Behaviour Driven
Development
Fixed in development/QA
REQUIREMENTS DEFECT
50-60%
Requirements Defects
100-200%
All stakeholders involved in the discussion drives out clear and concise
specifications centred around business value.
Turn the specification into acceptance tests that guarantees the software
does as it is intended
Cucumber
Ruby
Born 2007-2008
Cuke4Duke
Cucumber-JVM
Maven Dependencies
cucumberjava
cucumberjunit
cucumberpicocontainer
cucumberguice
cucumberspring
Maven Dependencies
< dependency>
< groupId> info.cukes< /groupId>
< artifactId> cucum ber-picocontainer< /artifactId>
< version> ${cucum ber.version}< /version>
< /dependency>
< dependency>
< groupId> info.cukes< /groupId>
< artifactId> cucum ber-junit< /artifactId>
< version> ${cucum ber.version}< /version>
< /dependency>
JUnit Runner
i m p o r t o r g . j u n i t . r u n n e r. R u n W i t h ;
i m p o r t c u c u m b e r. j u n i t . C u c u m b e r ;
@ R u n W i t h ( C u c u m b e r. c l a s s )
public class RunnerIT {
}
JUnit Runner 2
Body
Arguments
Step Definitions
Step Annotations
import cucumber.annotation.en.*;
Each Gherkin step keyword has a Annotation
@ W h e n ( " ^ we wa n t t o st o p t ra ffi c $ " )
p u b l i c vo i d m eth o d Na m e ( ) { }
Passed
Pending
Skipped
Failed
Regex Lesson
Cucumber uses Regular Expressions to match steps to
definitions.
Capturing Arguments
@ G iven ("^ an ow ner w ith a pet called \"Sly\"$")
p u b lic void an _ow n er_w ith _a_p et_called () {
Capturing Arguments 2
Type Conversion
Date Formats
@Given ("^today is (.+)$")
public void today_is(Date date) {
.
}
Dates are recognized if its a format from the DateFormat
class
Date Formats
SHORT is completely numeric, such as 12.13.52 or 3:30pm
MEDIUM is longer, such as Jan 12, 1952
LONG is longer, such as January 12, 1952 or 3:30:32pm
FULL is pretty completely specified, such as Tuesday, April
12, 1952 AD or 3:30:42pm PST.
Date Formats
import cucumber.DateFormat;
@Given ("^today is (.+)$")
public void today_is(
@DateFormat ("yyyy-MM-dd") Date date) {
.
}
Further information
Official website: cukes.info
Github: github.com/cucumber/cucumber-jvm
Hindsight Software: hindsighttesting.com
Thank you
Alan Parkinson