SlideShare une entreprise Scribd logo
1  sur  54
Télécharger pour lire hors ligne
#ATAGTR2016 Global Testing Retreat Pune 2016 © S
COOL JVM TOOLS TO HELP
YOU TEST
Schalk W. Cronjé
1
ABOUT ME
Email:
Twitter / Ello : @ysb33r
ysb33r@gmail.com
2
TECHNICAL TESTER
Work on coding skills
Think
Be open-minded
Testing is even more important that development.
3
LET’S REVIEW OUR TESTS
4 . 1
LET’S GET UNIT TESTING
class CalculatorSpec extends Specification {
def "A calculator must be able to add numbers"() {
given: 'That I have a calculator'
def calc = new Calculator()
when: "I add 2, 3 and -20"
def answer = calc.plus 2,3,-20
then: "The answer should be -15"
answer == -15
}
}
4 . 2
WHEN THIS TEST FAILS
4 . 3
WHEN THIS TEST FAILS
4 . 4
SPOCK FRAMEWORK
Built on top of JUnit 4.x.
Use it with all your JUnit tools!
Use for more than just unit tests.
Mocks & stubs included
Easily test Java, Groovy, Kotlin, Scala etc.
4 . 5
DATA-DRIVEN TESTS
@Unroll
def "A calculator must be able to multiply"() {
given: 'That I have a multiplying calculator'
def calc = new Calculator()
expect: "The answer to be #answer"
answer == calc.multiply (a,b,c)
where: "The operation is #a * #b * #c"
a | b | c || answer
3 | 7 | 5 || 105
1 | 3 | 0 || 0
2 | -1| 1 || -2
}
4 . 6
ANOTHER COOL FAILURE REPORT
4 . 7
HANDLING EXCEPTIONS
def "Dividing by zero should throw an exception"() {
given: 'That I have a dividing calculator'
def calc = new Calculator()
when: "I divide by zero"
calc.divide 1,0
then: "I expect an error"
thrown(ArithmeticException)
}
4 . 8
MOCK OUT INTERFACES
public interface RemoteCalculator {
public Number plus(Number... args);
}
def "Remote calculator"() {
given: "A remote calculator is available"
def calc = Mock(RemoteCalculator)
when: "Multiple items are sent for addition"
calc.plus 1,2,3,4,5
then: "The calculator is only called once"
1 * calc.plus(_)
}
4 . 9
SPOCK FRAMEWORK
Spock Framework:
Spock Reports
http://spockframework.github.io/spock/docs/1.0/index.html
https://github.com/renatoathaydes/spock-reports
4 . 10
WHAT IS THIS EVIL?
Underlying language is (Apache) Groovy
You don’t need to be a Groovy expert to be a power user of
many of these tools.
Groovy doesn’t need ; in most cases
Groovy does more with less punctuation, making it an ideal
choice for a DSL
In most cases lines that do not end on an operator is
considered a completed statement.
5 . 1
GROOVY VS JAVA
In Groovy:
All class members are public by default
No need to create getters/setters for public elds
Both static & dynamic typing supported
def means Object
5 . 2
CALLING METHODS
class Foo {
void bar( def a,def b ) {}
}
def foo = new Foo()
foo.bar( '123',456 )
foo.bar '123', 456
foo.with {
bar '123', 456
}
5 . 3
CALLING METHODS WITH CLOSURES
class Foo {
void bar( def a,Closure b ) {}
}
def foo = new Foo()
foo.bar( '123',{ println it } )
foo.bar ('123') {
println it
}
foo.bar '123', {
println it
}
5 . 4
MAPS IN GROOVY
Hashmaps in Groovy are simple to use
def myMap = [ plugin : 'java' ]
Maps are easy to pass inline to functions
project.apply( plugin : 'java' )
Which can also be written as
project.with {
apply plugin : 'java'
}
5 . 5
LISTS IN GROOVY
Lists in Groovy are simple too
def myList = [ 'clone', 'http://github.com/ysb33r/GradleLectures' ]
This makes it possible write a method call as
args 'clone', 'http://github.com/ysb33r/GradleLectures'
5 . 6
CLOSURE DELEGATION IN GROOVY
When a symbol cannot be resolved within a closure,
Groovy will look elsewhere
In Groovy speak this is called a Delegate.
This can be programmatically controlled via the
Closure.delegate property.
5 . 7
CLOSURE DELEGATION IN GROOVY
class Foo {
def target
}
class Bar {
Foo foo = new Foo()
void doSomething( Closure c ) {
c.delegate = foo
c()
}
}
Bar bar = new Bar()
bar.doSomething {
target = 10
}
5 . 8
MORE CLOSURE MAGIC
If a Groovy class has a method call(Closure), the object
can be passed a closure directly.
class Foo {
def call( Closure c) { /* ... */ }
}
Foo foo = new Foo()
foo {
println 'Hello, world'
}
// This avoids ugly syntax
foo.call({ println 'Hello, world' })
5 . 9
6 . 1
QUICK HTTP TESTING
QUICK HTTP TESTING
Quickly point to a remote or in-process server
Build payload in a simplistic manner
Execute the verb
Check the response in a readable manner
6 . 2
QUICK HTTP TESTING
def "The echo path should return what is send to it"() {
given: "A simple text request"
requestSpec { pay ->
pay.body.type(MediaType.PLAIN_TEXT_UTF8).text(' ')
}
when: "The data is posted"
post '/'
then: "It should be echoed back"
response.statusCode == 200
response.body.text == 'You said: '
}
6 . 3
7 . 1
 
7 . 2
RATPACK FRAMEWORK
Set of Java libraries for building modern HTTP applications.
Built on Java 8, Netty and reactive principles.
Groovy syntax for those who prefer it.
7 . 3
RATPACK’S TESTHTTPCLIENT
Can be used standalone
Use maven coordinates:
io.ratpack:ratpack-test:1.2.0
RATPACK’S TESTHTTPCLIENT
ApplicationUnderTest app = new ApplicationUnderTest() {
@Override
URI getAddress() { "http://127.0.0.1:${PORT}".toURI() }
}
@Delegate TestHttpClient client = TestHttpClient.testHttpClient(app)
def "The echo path should return what is send to it"() {
given: "A simple text request"
requestSpec { pay ->
pay.body.type(MediaType.PLAIN_TEXT_UTF8).text(' ')
}
when: "The data is posted"
post '/'
then: "It should be echoed back"
response.statusCode == 200
response.body.text == 'You said: '
}
7 . 4
OFFLINE API TESTING
Sometimes you simply have to use a live site for testing
Mocking & stubbing simply not good enough
Need live data
Do not want to overload service with unnecessary test
data
Want to test of ine
8 . 1
OFFLINE API TESTING
@Betamax(tape='files')
def "Source jar must be posted"() {
given: 'The list of files is requested from the repository'
def list =
get path : "${REPO_ROOT}/bintray-gradle-plugin/files"
expect: 'The bintray source jar should be included'
list?.find {
it?.path ==
'org.ysb33r.gradle/bintray/0.0.5/bintray-0.0.5-sources.jar'
}
}
8 . 2
9 . 1
 
BETAMAX
Allows record & playpack
Mocks external HTTP resources
Web services
REST APIs
Stores recordings in YAML
Easy to edit
Commit to source control
Remember to sanitize auth credentials!
9 . 2
DEMO
9 . 3
9 . 4
CREATE RECORDER
@Shared ProxyConfiguration configuration = ProxyConfiguration.builder().
tapeRoot(new File('/path/to/tapes')).
ignoreLocalhost(false).
sslEnabled(true).
build()
@Rule RecorderRule recorder = new RecorderRule(configuration)
 
http://betamax.software
https://github.com/betamaxteam/betamax
9 . 5
WEBSITE TESTING
One of the most predominant area of testing of this decade
Test-driven webpage development is less effort in long run
Selenium is the leading tool
Selenium tests can be overly verbose
10 . 1
TRIVIAL TEST EXAMPLE
def "Learn about testing checkboxes"() {
when: "I go to that the-internet site"
go "${webroot}/checkboxes"
then: 'I am expecting Checkbox page'
$('h3').text() == 'Checkboxes'
and: 'The checkbox states are no & yes'
$(By.id('checkboxes')).$('input')*.@checked == ['','true']
}
10 . 2
11 . 1
 
GEB
Integrates with
Spock Framework
JUnit
TestNG
Cucumber-JVM
Makes Selenium readable
Anything you can do in Selenium you can do in Geb
11 . 2
TRIVIAL TEST EXAMPLE COMPLETE
class CheckboxExampleSpec extends GebSpec {
def "Learn about testing checkboxes"() {
when: "I go to that the-internet site"
go "${webroot}/checkboxes"
then: 'I am expecting Checkbox page'
$('h3').text() == 'Checkboxes'
and: 'The checkbox states are no & yes'
$(By.id('checkboxes')).$('input')*.@checked == ['','true']
}
}
11 . 3
GRABBING SCREENSHOTS
class CheckboxReportingSpec extends GebReportingSpec {
def 'Learn about testing checkboxes'() {
when: 'I go to that the-internet site'
go "${webroot}/checkboxes"
report 'checkbox-screen'
then: 'I am expecting Checkbox page'
$('h3').text() == 'Checkboxes'
and: 'The checkbox states are no & yes'
$(By.id('checkboxes')).$('input')*.@checked == ['','true']
}
}
Keep record during test
Stores HTML & PNG.
11 . 4
GRABBING SCREENSHOTS
11 . 5
 
@GemFramework
http://gebish.org
11 . 6
TIE IT TOGETHER
Automation is very important for effectiveness and time-
to-market
Ability to run all tests locally, under CI and under special
environments
Modern testers needs to know about deployment
12
13 . 1
 
13 . 2
GRADLE
Very modern, next-generation build & deployment pipeline
tool
DSL is based on Groovy
Vast collection of plugins
GRADLE
apply plugin : 'groovy'
repositories {
jcenter()
}
dependencies {
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile "org.gebish:geb-spock:0.13.0"
testCompile "org.seleniumhq.selenium:selenium-api:2.53.0"
testRuntime "org.seleniumhq.selenium:selenium-support:2.53.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:2.53.0"
}
13 . 3
GRADLE
Make it easy to integrate development and complex testing
Deploy local & to remote sites via plugins
Use Docker local & remote
"I do not have means to test on my machine" becomes less
of an argument.
13 . 4
 
Website:
Plugins Portal:
User Forum:
@gradle
@DailyGradle
http://gradle.org
http://plugins.gradle.org
http://discuss.gradle.org
13 . 5
14
DEMO
 
http://leanpub.com/idiomaticgradle
15
ABOUT THIS PRESENTATION
Written in Asciidoctor (1.5.3.2)
Styled by asciidoctor-revealjs extension
Built using:
Gradle
gradle-asciidoctor-plugin
gradle-vfs-plugin
All code snippets tested as part of build
16
THANK YOU
Schalk Cronjé
ysb33r@gmail.com
@ysb33r

Contenu connexe

Tendances

Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...ZeroTurnaround
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradleLiviu Tudor
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Eric Wendelin
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Roberto Franchini
 
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
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-kyon mm
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Tomek Kaczanowski
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golangTing-Li Chou
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Joachim Baumann
 

Tendances (20)

Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
groovy & grails - lecture 10
groovy & grails - lecture 10groovy & grails - lecture 10
groovy & grails - lecture 10
 
Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!Gradle 3.0: Unleash the Daemon!
Gradle 3.0: Unleash the Daemon!
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
groovy & grails - lecture 9
groovy & grails - lecture 9groovy & grails - lecture 9
groovy & grails - lecture 9
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
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
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
 
Gradle
GradleGradle
Gradle
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
 

Similaire à Cool JVM Tools to Help You Test

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsYura Nosenko
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock FrameworkEugene Dvorkin
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.xYiguang Hu
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everythingnoelrap
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and ProsperKen Kousen
 
Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testingPeter Edwards
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
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
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Arnaud Giuliani
 
The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockNaresha K
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good TestsTomek Kaczanowski
 

Similaire à Cool JVM Tools to Help You Test (20)

HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
Spock: Test Well and Prosper
Spock: Test Well and ProsperSpock: Test Well and Prosper
Spock: Test Well and Prosper
 
Real world cross-platform testing
Real world cross-platform testingReal world cross-platform testing
Real world cross-platform testing
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Unit testing
Unit testingUnit testing
Unit testing
 
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
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
 
The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests2013 DevFest Vienna - Bad Tests, Good Tests
2013 DevFest Vienna - Bad Tests, Good Tests
 

Plus de Schalk Cronjé

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldSchalk Cronjé
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in AsciidoctorSchalk Cronjé
 
Probability Management
Probability ManagementProbability Management
Probability ManagementSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instructionSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability ManagementSchalk Cronjé
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem UnsolvedSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot WorldSchalk Cronjé
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingSchalk Cronjé
 
Tree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingTree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingSchalk Cronjé
 
Beyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKBeyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKSchalk Cronjé
 
Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Schalk Cronjé
 
Beyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingBeyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingSchalk Cronjé
 
Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Schalk Cronjé
 
RfC2822 for Mere Mortals
RfC2822 for Mere MortalsRfC2822 for Mere Mortals
RfC2822 for Mere MortalsSchalk Cronjé
 

Plus de Schalk Cronjé (20)

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM World
 
DocuOps & Asciidoctor
DocuOps & AsciidoctorDocuOps & Asciidoctor
DocuOps & Asciidoctor
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in Asciidoctor
 
Probability Management
Probability ManagementProbability Management
Probability Management
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instruction
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instruction
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability Management
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem Unsolved
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot World
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused Testing
 
Asciidoctor in 15min
Asciidoctor in 15minAsciidoctor in 15min
Asciidoctor in 15min
 
Tree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & TestingTree of Knowledge - About Philosophy, Unity & Testing
Tree of Knowledge - About Philosophy, Unity & Testing
 
Beyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MKBeyond estimates - Overview at Agile:MK
Beyond estimates - Overview at Agile:MK
 
Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)Groovy VFS (with 1.0 news)
Groovy VFS (with 1.0 news)
 
Beyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile ForecastingBeyond estimates - Reflection on the state of Agile Forecasting
Beyond estimates - Reflection on the state of Agile Forecasting
 
Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"Seeking enligtenment - A journey of "Why?" rather than "How?"
Seeking enligtenment - A journey of "Why?" rather than "How?"
 
RfC2822 for Mere Mortals
RfC2822 for Mere MortalsRfC2822 for Mere Mortals
RfC2822 for Mere Mortals
 
Groovy VFS
Groovy VFSGroovy VFS
Groovy VFS
 

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 

Dernier (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 

Cool JVM Tools to Help You Test

  • 1. #ATAGTR2016 Global Testing Retreat Pune 2016 © S COOL JVM TOOLS TO HELP YOU TEST Schalk W. Cronjé
  • 2. 1 ABOUT ME Email: Twitter / Ello : @ysb33r ysb33r@gmail.com
  • 3. 2 TECHNICAL TESTER Work on coding skills Think Be open-minded Testing is even more important that development.
  • 5. 4 . 1 LET’S GET UNIT TESTING class CalculatorSpec extends Specification { def "A calculator must be able to add numbers"() { given: 'That I have a calculator' def calc = new Calculator() when: "I add 2, 3 and -20" def answer = calc.plus 2,3,-20 then: "The answer should be -15" answer == -15 } }
  • 6. 4 . 2 WHEN THIS TEST FAILS
  • 7. 4 . 3 WHEN THIS TEST FAILS
  • 8. 4 . 4 SPOCK FRAMEWORK Built on top of JUnit 4.x. Use it with all your JUnit tools! Use for more than just unit tests. Mocks & stubs included Easily test Java, Groovy, Kotlin, Scala etc.
  • 9. 4 . 5 DATA-DRIVEN TESTS @Unroll def "A calculator must be able to multiply"() { given: 'That I have a multiplying calculator' def calc = new Calculator() expect: "The answer to be #answer" answer == calc.multiply (a,b,c) where: "The operation is #a * #b * #c" a | b | c || answer 3 | 7 | 5 || 105 1 | 3 | 0 || 0 2 | -1| 1 || -2 }
  • 10. 4 . 6 ANOTHER COOL FAILURE REPORT
  • 11. 4 . 7 HANDLING EXCEPTIONS def "Dividing by zero should throw an exception"() { given: 'That I have a dividing calculator' def calc = new Calculator() when: "I divide by zero" calc.divide 1,0 then: "I expect an error" thrown(ArithmeticException) }
  • 12. 4 . 8 MOCK OUT INTERFACES public interface RemoteCalculator { public Number plus(Number... args); } def "Remote calculator"() { given: "A remote calculator is available" def calc = Mock(RemoteCalculator) when: "Multiple items are sent for addition" calc.plus 1,2,3,4,5 then: "The calculator is only called once" 1 * calc.plus(_) }
  • 13. 4 . 9 SPOCK FRAMEWORK Spock Framework: Spock Reports http://spockframework.github.io/spock/docs/1.0/index.html https://github.com/renatoathaydes/spock-reports
  • 14. 4 . 10 WHAT IS THIS EVIL? Underlying language is (Apache) Groovy You don’t need to be a Groovy expert to be a power user of many of these tools. Groovy doesn’t need ; in most cases Groovy does more with less punctuation, making it an ideal choice for a DSL In most cases lines that do not end on an operator is considered a completed statement.
  • 15. 5 . 1 GROOVY VS JAVA In Groovy: All class members are public by default No need to create getters/setters for public elds Both static & dynamic typing supported def means Object
  • 16. 5 . 2 CALLING METHODS class Foo { void bar( def a,def b ) {} } def foo = new Foo() foo.bar( '123',456 ) foo.bar '123', 456 foo.with { bar '123', 456 }
  • 17. 5 . 3 CALLING METHODS WITH CLOSURES class Foo { void bar( def a,Closure b ) {} } def foo = new Foo() foo.bar( '123',{ println it } ) foo.bar ('123') { println it } foo.bar '123', { println it }
  • 18. 5 . 4 MAPS IN GROOVY Hashmaps in Groovy are simple to use def myMap = [ plugin : 'java' ] Maps are easy to pass inline to functions project.apply( plugin : 'java' ) Which can also be written as project.with { apply plugin : 'java' }
  • 19. 5 . 5 LISTS IN GROOVY Lists in Groovy are simple too def myList = [ 'clone', 'http://github.com/ysb33r/GradleLectures' ] This makes it possible write a method call as args 'clone', 'http://github.com/ysb33r/GradleLectures'
  • 20. 5 . 6 CLOSURE DELEGATION IN GROOVY When a symbol cannot be resolved within a closure, Groovy will look elsewhere In Groovy speak this is called a Delegate. This can be programmatically controlled via the Closure.delegate property.
  • 21. 5 . 7 CLOSURE DELEGATION IN GROOVY class Foo { def target } class Bar { Foo foo = new Foo() void doSomething( Closure c ) { c.delegate = foo c() } } Bar bar = new Bar() bar.doSomething { target = 10 }
  • 22. 5 . 8 MORE CLOSURE MAGIC If a Groovy class has a method call(Closure), the object can be passed a closure directly. class Foo { def call( Closure c) { /* ... */ } } Foo foo = new Foo() foo { println 'Hello, world' } // This avoids ugly syntax foo.call({ println 'Hello, world' })
  • 23. 5 . 9 6 . 1 QUICK HTTP TESTING
  • 24. QUICK HTTP TESTING Quickly point to a remote or in-process server Build payload in a simplistic manner Execute the verb Check the response in a readable manner
  • 25. 6 . 2 QUICK HTTP TESTING def "The echo path should return what is send to it"() { given: "A simple text request" requestSpec { pay -> pay.body.type(MediaType.PLAIN_TEXT_UTF8).text(' ') } when: "The data is posted" post '/' then: "It should be echoed back" response.statusCode == 200 response.body.text == 'You said: ' }
  • 26. 6 . 3 7 . 1  
  • 27. 7 . 2 RATPACK FRAMEWORK Set of Java libraries for building modern HTTP applications. Built on Java 8, Netty and reactive principles. Groovy syntax for those who prefer it.
  • 28. 7 . 3 RATPACK’S TESTHTTPCLIENT Can be used standalone Use maven coordinates: io.ratpack:ratpack-test:1.2.0
  • 29. RATPACK’S TESTHTTPCLIENT ApplicationUnderTest app = new ApplicationUnderTest() { @Override URI getAddress() { "http://127.0.0.1:${PORT}".toURI() } } @Delegate TestHttpClient client = TestHttpClient.testHttpClient(app) def "The echo path should return what is send to it"() { given: "A simple text request" requestSpec { pay -> pay.body.type(MediaType.PLAIN_TEXT_UTF8).text(' ') } when: "The data is posted" post '/' then: "It should be echoed back" response.statusCode == 200 response.body.text == 'You said: ' }
  • 30. 7 . 4 OFFLINE API TESTING Sometimes you simply have to use a live site for testing Mocking & stubbing simply not good enough Need live data Do not want to overload service with unnecessary test data Want to test of ine
  • 31. 8 . 1 OFFLINE API TESTING @Betamax(tape='files') def "Source jar must be posted"() { given: 'The list of files is requested from the repository' def list = get path : "${REPO_ROOT}/bintray-gradle-plugin/files" expect: 'The bintray source jar should be included' list?.find { it?.path == 'org.ysb33r.gradle/bintray/0.0.5/bintray-0.0.5-sources.jar' } }
  • 32. 8 . 2 9 . 1  
  • 33. BETAMAX Allows record & playpack Mocks external HTTP resources Web services REST APIs Stores recordings in YAML Easy to edit Commit to source control Remember to sanitize auth credentials!
  • 35. 9 . 3 9 . 4 CREATE RECORDER @Shared ProxyConfiguration configuration = ProxyConfiguration.builder(). tapeRoot(new File('/path/to/tapes')). ignoreLocalhost(false). sslEnabled(true). build() @Rule RecorderRule recorder = new RecorderRule(configuration)
  • 37. 9 . 5 WEBSITE TESTING One of the most predominant area of testing of this decade Test-driven webpage development is less effort in long run Selenium is the leading tool Selenium tests can be overly verbose
  • 38. 10 . 1 TRIVIAL TEST EXAMPLE def "Learn about testing checkboxes"() { when: "I go to that the-internet site" go "${webroot}/checkboxes" then: 'I am expecting Checkbox page' $('h3').text() == 'Checkboxes' and: 'The checkbox states are no & yes' $(By.id('checkboxes')).$('input')*.@checked == ['','true'] }
  • 39. 10 . 2 11 . 1  
  • 40. GEB Integrates with Spock Framework JUnit TestNG Cucumber-JVM Makes Selenium readable Anything you can do in Selenium you can do in Geb
  • 41. 11 . 2 TRIVIAL TEST EXAMPLE COMPLETE class CheckboxExampleSpec extends GebSpec { def "Learn about testing checkboxes"() { when: "I go to that the-internet site" go "${webroot}/checkboxes" then: 'I am expecting Checkbox page' $('h3').text() == 'Checkboxes' and: 'The checkbox states are no & yes' $(By.id('checkboxes')).$('input')*.@checked == ['','true'] } }
  • 42. 11 . 3 GRABBING SCREENSHOTS class CheckboxReportingSpec extends GebReportingSpec { def 'Learn about testing checkboxes'() { when: 'I go to that the-internet site' go "${webroot}/checkboxes" report 'checkbox-screen' then: 'I am expecting Checkbox page' $('h3').text() == 'Checkboxes' and: 'The checkbox states are no & yes' $(By.id('checkboxes')).$('input')*.@checked == ['','true'] } } Keep record during test Stores HTML & PNG.
  • 43. 11 . 4 GRABBING SCREENSHOTS
  • 45. 11 . 6 TIE IT TOGETHER Automation is very important for effectiveness and time- to-market Ability to run all tests locally, under CI and under special environments Modern testers needs to know about deployment
  • 47. 13 . 2 GRADLE Very modern, next-generation build & deployment pipeline tool DSL is based on Groovy Vast collection of plugins
  • 48. GRADLE apply plugin : 'groovy' repositories { jcenter() } dependencies { testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' testCompile "org.gebish:geb-spock:0.13.0" testCompile "org.seleniumhq.selenium:selenium-api:2.53.0" testRuntime "org.seleniumhq.selenium:selenium-support:2.53.0" testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:2.53.0" }
  • 49. 13 . 3 GRADLE Make it easy to integrate development and complex testing Deploy local & to remote sites via plugins Use Docker local & remote "I do not have means to test on my machine" becomes less of an argument.
  • 50. 13 . 4   Website: Plugins Portal: User Forum: @gradle @DailyGradle http://gradle.org http://plugins.gradle.org http://discuss.gradle.org
  • 53. 15 ABOUT THIS PRESENTATION Written in Asciidoctor (1.5.3.2) Styled by asciidoctor-revealjs extension Built using: Gradle gradle-asciidoctor-plugin gradle-vfs-plugin All code snippets tested as part of build