SlideShare une entreprise Scribd logo
1  sur  55
Is Groovy Better For
Testing Than Java?
Trisha Gee (@trisha_gee)
Developer Advocate, JetBrains
TDD
Test Driven Development Design
Acceptance, Integration, System,
Performance, Unit Tests
Shared understanding & pair
programming
Open source
Downloadable library
The most used driver
The oldest driver
About to be re-written
But the tests were…
Ugly
Inconsistent
Hard to understand
“Test second”
Tightly tied to implementation
Functional / integration
Testing more than one thing
Mostly “happy path”
Not helpful for understanding
the system’s expected behaviour
On the plus side…
The project does have tests
…but no coherent approach to
testing
The tests should:
Be readable
Be easy to write
Describe the expected behaviour
of the system
Possible solutions
•EasyMock / Mockito / JMock
•Home-grown mocking/stubbing
•Standards / Examples
•DSL – Domain Specific Language
•Hamcrest matchers
•Spock
A week to spike Spock
•Questions to answer:
• Is it fast enough to learn that a week can give noticeable
progress?
• Is using Groovy to test Java too big a context switch?
• What benefits does it give us over our current tests?
• What benefits does it give us over the alternatives?
• Will it help developers write “better” tests?
• Does is make the tests more understandable?
Intro to Spock & Groovy
•DBCollectionFunctionalSpecification
• 'should update multiple documents‘
• 'drop index should error if index does not exist‘
•JMXConnectionPoolListenerSpecification
• 'should create a valid ObjectName for ipv4 addresses'
The old tests were ugly
•MongoClientURITest
•-> MongoClientURISpecification
Mocking should be easy
•IterableCodecTest
•-> IterableCodecSpecification
Stubbing should also be easy
•DBCursorFunctionalSpecification
• 'should use provided decoder factory‘
Hamcrest makes testing easier
•DBCollectionFunctionalSpecification
• 'should return a list of all the values of a given field
without duplicates‘
The gains are not always that big
•DBCursorOldTest.testTailableImplicitAwaitOnHas
NextOriginal
•->DBCursorFunctionalSpecification
• 'should block and wait for new documents when cursor is
tailable'
Answers
•Is it fast enough to learn that a week can give
noticeable progress?
• Yes.
• And if in doubt, write Java
Answers
•Is using Groovy to test Java too big a context
switch?
• No. Although you’ll want the new Map syntax in prod
code
Answers
•What benefits does it give us over our current
tests?
• Readability, structure, mocking, stubbing, data driven
testing
Answers
•What benefits does it give us over the
alternatives?
• Mocking and stubbing are very easy and very readable
• A DSL or DSL-style could be introduced via Groovy
• You can still make use of Hamcrest Matchers
Answers
•Will it help developers write “better” tests?
• Yes
Answers
•Does is make the tests more understandable?
• Yes
So which is best, Groovy or
Java?
Lines of Code
Ease of Understanding
Ease of Writing
Performance
Fast Feedback
IDE Support
Ease of Learning (for Java devs)
Ease of Learning (for other devs)
Other Advantages
•Shows how the library can be used from Groovy
•Allows us to learn a new language without
impacting production
•Can just write Java
Other Disadvantages
•Requires investment in learning to get full
advantages
•Some context switching
•We now have (at least) two different ways to test
our code
•…and a possible migration task
Conclusion
•Groovy & Spock are:
• Easy to read and understand
• Easy to write
• Easy to learn
•Java and JUnit are:
• Well understood standards
• Type safe and performant
• Better supported by IDEs
http://bit.ly/GroovyVsJava
Resources
@trisha_gee

Contenu connexe

Tendances

Roy Osherove TDD From Scratch
Roy Osherove TDD From ScratchRoy Osherove TDD From Scratch
Roy Osherove TDD From Scratch
Roy Osherove
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
Einar Ingebrigtsen
 

Tendances (20)

Continuous Integration: Finding problems soonest
Continuous Integration: Finding problems soonestContinuous Integration: Finding problems soonest
Continuous Integration: Finding problems soonest
 
Four Stages of Automated Testing by Bradley Temple
Four Stages of Automated Testing by Bradley TempleFour Stages of Automated Testing by Bradley Temple
Four Stages of Automated Testing by Bradley Temple
 
Code Review
Code ReviewCode Review
Code Review
 
Clean code - Getting your R&D on board
Clean code - Getting your R&D on boardClean code - Getting your R&D on board
Clean code - Getting your R&D on board
 
@LinkingNote annotation in YATSPEC
@LinkingNote annotation in YATSPEC@LinkingNote annotation in YATSPEC
@LinkingNote annotation in YATSPEC
 
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
АНТОН МУЖАЙЛО «Test Team Development and Management Techniques»
 
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
АННА ТИМОФІЄВА & СЕРГІЙ МАЛИНОВСЬКИЙ «Tools and Tips of video connection test...
 
OSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be MissingOSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be Missing
 
Writing Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designsWriting Better Tests - Applying Clean-Code TDD at 99designs
Writing Better Tests - Applying Clean-Code TDD at 99designs
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users Anonymous
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
 
Unit testing
Unit testingUnit testing
Unit testing
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
Adopting Agile
Adopting AgileAdopting Agile
Adopting Agile
 
Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)Test Driven Development (TDD) & Continuous Integration (CI)
Test Driven Development (TDD) & Continuous Integration (CI)
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Roy Osherove TDD From Scratch
Roy Osherove TDD From ScratchRoy Osherove TDD From Scratch
Roy Osherove TDD From Scratch
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
What would Jesus Developer do?
What would Jesus Developer do?What would Jesus Developer do?
What would Jesus Developer do?
 

En vedette

Cucumber on the JVM with Groovy
Cucumber on the JVM with GroovyCucumber on the JVM with Groovy
Cucumber on the JVM with Groovy
Richard Paul
 

En vedette (12)

Migrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from EclipseMigrating to IntelliJ IDEA from Eclipse
Migrating to IntelliJ IDEA from Eclipse
 
Cucumber on the JVM with Groovy
Cucumber on the JVM with GroovyCucumber on the JVM with Groovy
Cucumber on the JVM with Groovy
 
Staying Ahead of the Curve
Staying Ahead of the CurveStaying Ahead of the Curve
Staying Ahead of the Curve
 
TDD and BDD in Java 8 - what's in it for me?
TDD and BDD in Java 8 - what's in it for me?TDD and BDD in Java 8 - what's in it for me?
TDD and BDD in Java 8 - what's in it for me?
 
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
 
Tdd - introduction
Tdd - introductionTdd - introduction
Tdd - introduction
 
Introduction to TDD and Mocking
Introduction to TDD and MockingIntroduction to TDD and Mocking
Introduction to TDD and Mocking
 
RSpec & TDD Tutorial
RSpec & TDD TutorialRSpec & TDD Tutorial
RSpec & TDD Tutorial
 
Frame switcher library
Frame switcher libraryFrame switcher library
Frame switcher library
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 

Similaire à Is Groovy better for testing than Java?

GeneralAssemb.ly Summer Program: Tech from the Ground Up
GeneralAssemb.ly Summer Program: Tech from the Ground UpGeneralAssemb.ly Summer Program: Tech from the Ground Up
GeneralAssemb.ly Summer Program: Tech from the Ground Up
Daniel Doubrovkine
 
Trends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa CrispinTrends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa Crispin
Directi Group
 

Similaire à Is Groovy better for testing than Java? (20)

GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
 
2014 toronto-torbug
2014 toronto-torbug2014 toronto-torbug
2014 toronto-torbug
 
Clean tests
Clean testsClean tests
Clean tests
 
TLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing TestingTLC2018 Shyam Sunder: Legoizing Testing
TLC2018 Shyam Sunder: Legoizing Testing
 
DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
GeneralAssemb.ly Summer Program: Tech from the Ground Up
GeneralAssemb.ly Summer Program: Tech from the Ground UpGeneralAssemb.ly Summer Program: Tech from the Ground Up
GeneralAssemb.ly Summer Program: Tech from the Ground Up
 
TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012
 
TDD for Testers Workshop
TDD for Testers WorkshopTDD for Testers Workshop
TDD for Testers Workshop
 
Waterfalls for agile cambridge
Waterfalls for agile cambridgeWaterfalls for agile cambridge
Waterfalls for agile cambridge
 
A la découverte des google/test (aka gtest)
A la découverte des google/test (aka gtest)A la découverte des google/test (aka gtest)
A la découverte des google/test (aka gtest)
 
Creativity vs Best Practices
Creativity vs Best PracticesCreativity vs Best Practices
Creativity vs Best Practices
 
Trends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa CrispinTrends in Agile Testing by Lisa Crispin
Trends in Agile Testing by Lisa Crispin
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
 
HackYale 0-60 in Startup Tech
HackYale 0-60 in Startup TechHackYale 0-60 in Startup Tech
HackYale 0-60 in Startup Tech
 
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
Start with passing tests (tdd for bugs) v0.5 (22 sep 2016)
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
 

Plus de Trisha Gee

Plus de Trisha Gee (20)

Career Advice for Architects
Career Advice for Architects Career Advice for Architects
Career Advice for Architects
 
Is boilerplate code really so bad?
Is boilerplate code really so bad?Is boilerplate code really so bad?
Is boilerplate code really so bad?
 
Career Advice for Programmers - ProgNET London
Career Advice for Programmers - ProgNET LondonCareer Advice for Programmers - ProgNET London
Career Advice for Programmers - ProgNET London
 
Is Boilerplate Code Really So Bad?
Is Boilerplate Code Really So Bad?Is Boilerplate Code Really So Bad?
Is Boilerplate Code Really So Bad?
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains Webinar
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Career Advice for Programmers
Career Advice for Programmers Career Advice for Programmers
Career Advice for Programmers
 
Real World Java 9
Real World Java 9Real World Java 9
Real World Java 9
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Java 8 and 9 in Anger
Java 8 and 9 in AngerJava 8 and 9 in Anger
Java 8 and 9 in Anger
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
Refactoring to Java 8 (QCon New York)
Refactoring to Java 8 (QCon New York)Refactoring to Java 8 (QCon New York)
Refactoring to Java 8 (QCon New York)
 
Refactoring to Java 8 (Devoxx UK)
Refactoring to Java 8 (Devoxx UK)Refactoring to Java 8 (Devoxx UK)
Refactoring to Java 8 (Devoxx UK)
 
Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)
 
Staying Ahead of the Curve
Staying Ahead of the CurveStaying Ahead of the Curve
Staying Ahead of the Curve
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx France
 
Speaker Clinic (Novice Speakers)
Speaker Clinic (Novice Speakers)Speaker Clinic (Novice Speakers)
Speaker Clinic (Novice Speakers)
 
Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Is Groovy better for testing than Java?

Notes de l'éditeur

  1. Who’s using IntelliJ IDEA? …for groovy? Who’s using Groovy? Who’s heard of Spock? Who’s using Spock?
  2. Mentioned in this morning’s talk about reactive frameworks
  3. Had a CI environment for running the full suite in 40 minutes Failed Fast
  4. “Test second” Tightly tied to implementation Functional/integration tests Often testing more than one thing Mostly “happy path”
  5. Functional/integration tests Often testing more than one thing Mostly “happy path”
  6. We do see the need of having tests We encourage contributors to write tests for their code We require tests for code review We have a team of experienced Java developers
  7. Have a coherent… well, any… approach to testing Have any unit (i.e. fast) tests Have examples of good tests Know what the current tests really cover
  8. And easy to understand
  9. So developers write them! Preferably writing GOOD tests
  10. Given/when/then encourages developers to think about what they’re really testing Easy mocking and stubbing means it’s much easier to write unit tests Data driven testing makes it really easy to add edge cases, unhappy paths, what-ifs
  11. Nice syntax for working with Maps Pretty ways of creating Lists String method names Given/when/then gives clear structure Groovy’s nice features for Strings Using closures reduces boilerplate Overall, even when nasty test-too-many-things tests are ported with a straight conversion, Spock’s conventions and Groovy’s boilerplate removal already make it more understandable
  12. Groovy: Reduced boilerplate, specifically for Strings, Maps, Lists and inner classes Dynamic language means we only care about types when we really care Advantages of Spock: Mocking is easy and readable, and requires far fewer dependencies Stubbing is similarly painless Data Driven Testing is fantastic for testing many inputs vs output Disadv: Spock requires lines for given/when/then Advantages of Java: If we tested using Java 8 we get some reduced boilerplate Disadvantages of Java Boilerplate is better off hidden behind builders and utils No lovely syntax for Collections Creating Strings is ugly
  13. Groovy: Reduced boilerplate, specifically for Strings, Maps, Lists and inner classes Dynamic language means we only care about types when we really care Advantages of Spock: Forced structure Mocking is readable Stubbing is similarly painless Data Driven Testing is fantastic for testing many inputs vs output Testing of Exceptions is much more comprehensive Given/when/then helps developers understand what’s going on when reading Strings as method names aids understanding Advantages of Java: Type safety: you can see what things are immediately More familiar for Java developers to read Disadvantages of Java Too easy to clutter up tests with boilerplate Too easy to write badly structured tests No lovely syntax for Collections
  14. Groovy: Reduced boilerplate, specifically for Strings, Maps, Lists and inner classes Dynamic language means we only care about types when we really care Advantages of Spock: Forced structure Mocking is easy and requires far fewer dependencies Stubbing is similarly painless (but takes a bit of practice) Both of these means it’s easier to write fast unit tests Data Driven Testing is fantastic for testing many inputs vs output Testing of Exceptions is much more comprehensive Given/when/then helps developers structure the code when writing… Disadvantages of Spock/Groovy: Learning Curve Advantages of Java: Type safety: failures can be caught before running Type safety: refactoring is automagic More familiar for Java developers to write IDE support and autocomplete makes it easy to write stuff Disadvantages of Java No inherent structure to encourage good tests Requires more discipline to write “better” tests Unwieldy to work with collections Creating Strings is ugly
  15. Disadvantages of Groovy: Slower to run individual tests Less predictable (should be able to overcome with better tests) Advantages of Java: Faster (more importantly, more predictable) to run Disadvantages of Java If you’re not using Java 8, using some of the concurrency tools is verbose
  16. Disadvantages of Groovy: Slower to run individual tests Slow feedback on simple errors (runtime instead of compile time) Advantages of Spock: Given/when/then gets you thinking up front about how valuable your tests are Advantages of Java: Type safety: failures can be caught before running
  17. Groovy: Improving support Even dynamically typed objects have suggestions Disadvantages of Groovy: Refactoring is still not as good as Java Harder to do Test Driven Development Advantages of Spock: Syntax highlighting Advantages of Java: Type safety: failures can be caught before running Type safety: refactoring is automagic
  18. Advantages of Java: More familiar for Java developers to write and read
  19. Advantages of Java: More familiar for Java developers to write and read
  20. Groovy and Spock make it really easy to encourage developers to write tests And to write GOOD tests Java and Junit are FAST, fast to run, fast to write, fast to get feedback Well integrated with the IDE, better for writing tests first