SlideShare a Scribd company logo
1 of 23
Writing quick and
beautiful
automation code
Introduction to Hamcrest and Lambdaj
Cristian Coțoi
May 20 2013
•BDD (Agile) has new needs
•What is hamcrest
•What is lambdaj
•Improvement
Agenda
2
IN YOUR ZONE
Purpose
3
•http://hamcrest.org
•“Hamcrest it is not a testing library:
it just happens that matchers are
very useful for testing.”
•Matching allows writing of lines that
are close-to natural language
•Anagram of “matchers”
•http://code.google.com/p/lambdaj/
•Access collections without explicit
loops
•Operations include: items
filtering, converting, sorting, method
invoking, concatenate etc.
Hamcrest Lambdaj
IN YOUR ZONE
Why Hamcrest
4
•Clarity
•assertThat(a, is(“3”));
•assertEquals(a, “3”);
•Speed
•Not necessarily applicable for isNull() or isNotNull()
•assertThat(list, hasItems(“banana”, “paple”, “papoi”));
IN YOUR ZONE
Hamcrest (some of the common matchers)
5
•Core
• is
•Logical
• allOf - like Java &&
• anyOf - like Java ||
• not
•Object
• equalTo - test object equality using Object.equals
• notNullValue, nullValue - test for null
IN YOUR ZONE
Hamcrest (some of the common matchers)
6
•Collections
• hasEntry, hasKey, hasValue - test a map contains an entry, key or value
• hasItem, hasItems - test a collection contains elements
•Number
• closeTo - test floating point values are close to a given value
• greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo - test ordering
•Text
• equalToIgnoringCase
• containsString, endsWith, startsWith - test string matching
IN YOUR ZONE
Hamcrest
7
Imports
IN YOUR ZONE
Hamcrest Examples
8
•hasItem, hasItems
IN YOUR ZONE
Hamcrest examples
9
•hasItems (fail)
IN YOUR ZONE
Hamcrest examples
10
•hasEntry, hasValue, hasKey
IN YOUR ZONE
Hamcrest examples
11
•Numbers
IN YOUR ZONE
Hamcrest
12
•Actual automation code example
IN YOUR ZONE
Lambdaj
13
•It’s designed to easily manipulate collections.
•It uses Hamcrest matchers for filtering
IN YOUR ZONE
Why Lambdaj
14
•Readability
•Collections are very common
•Iterating over them is not dead-easy
•Loops are hard to read
•Operations for collections: Convert, Index, Filter, Sort, Extract
etc.
IN YOUR ZONE
Lambdaj examples
15
•Mathematical comparisons
•Mathematical operations
IN YOUR ZONE
Lambdaj examples
16
•Method invoke – add last name
IN YOUR ZONE
Lambdaj examples
17
•Select
IN YOUR ZONE
Lambdaj examples
18
•Youngest Papoi
IN YOUR ZONE
Lambdaj automation example
19
IN YOUR ZONE
Lambdaj limitations
20
•Null or empty collection in forEach
•Final class
IN YOUR ZONE
Benefits
21
•Integration with Agile methodologies (BDD)
•Clarity
•Speed
•Quick learning curve
•Extensive application
IN YOUR ZONE
Thank you
22
Cristian Coțoi| Senior Tester
IN YOUR ZONE
References
23
•Hamcrest
• http://code.google.com/p/hamcrest/wiki/Tutorial
• http://edgibbs.com/junit-4-with-hamcrest/
• http://rafaelnaufal.com/blog/2010/03/15/using-hamcrest-and-junit/ -
writing your own matchers
•LambdaJ
• http://code.google.com/p/lambdaj/
• http://code.google.com/p/lambdaj/wiki/LambdajFeatures

More Related Content

Similar to Writing quick and beautiful automation code

ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...Vyacheslav Lapin
 
Tips for Tuning Solr Search: No Coding Required
Tips for Tuning Solr Search: No Coding RequiredTips for Tuning Solr Search: No Coding Required
Tips for Tuning Solr Search: No Coding RequiredAcquia
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
 
CPAN Gems From The Far East
CPAN Gems From The Far EastCPAN Gems From The Far East
CPAN Gems From The Far Eastlestrrat
 
Cascalog at Strange Loop
Cascalog at Strange LoopCascalog at Strange Loop
Cascalog at Strange Loopnathanmarz
 
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016Alvaro Sanchez-Mariscal
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012Chris Westin
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkChris Westin
 
Scala Bay Meetup - The state of Scala code style and quality
Scala Bay Meetup - The state of Scala code style and qualityScala Bay Meetup - The state of Scala code style and quality
Scala Bay Meetup - The state of Scala code style and qualityJaime Jorge
 
ITB2017 - Slaying the ORM dragons with cborm
ITB2017 - Slaying the ORM dragons with cbormITB2017 - Slaying the ORM dragons with cborm
ITB2017 - Slaying the ORM dragons with cbormOrtus Solutions, Corp
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to LotuscriptBill Buchan
 
Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013Matt Tesauro
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03Derek Ashmore
 
Hadoop Spark - Reuniao SouJava 12/04/2014
Hadoop Spark - Reuniao SouJava 12/04/2014Hadoop Spark - Reuniao SouJava 12/04/2014
Hadoop Spark - Reuniao SouJava 12/04/2014soujavajug
 

Similar to Writing quick and beautiful automation code (20)

SolrCloud on Hadoop
SolrCloud on HadoopSolrCloud on Hadoop
SolrCloud on Hadoop
 
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
ITSubbotik - как скрестить ежа с ужом или подводные камни внедрения функциона...
 
Tips for Tuning Solr Search: No Coding Required
Tips for Tuning Solr Search: No Coding RequiredTips for Tuning Solr Search: No Coding Required
Tips for Tuning Solr Search: No Coding Required
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
CPAN Gems From The Far East
CPAN Gems From The Far EastCPAN Gems From The Far East
CPAN Gems From The Far East
 
Cascalog at Strange Loop
Cascalog at Strange LoopCascalog at Strange Loop
Cascalog at Strange Loop
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
Efficient HTTP applications on the JVM with Ratpack - Voxxed Days Berlin 2016
 
mongodb-aggregation-may-2012
mongodb-aggregation-may-2012mongodb-aggregation-may-2012
mongodb-aggregation-may-2012
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
 
Scala Bay Meetup - The state of Scala code style and quality
Scala Bay Meetup - The state of Scala code style and qualityScala Bay Meetup - The state of Scala code style and quality
Scala Bay Meetup - The state of Scala code style and quality
 
ITB2017 - Slaying the ORM dragons with cborm
ITB2017 - Slaying the ORM dragons with cbormITB2017 - Slaying the ORM dragons with cborm
ITB2017 - Slaying the ORM dragons with cborm
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to Lotuscript
 
遇見 Ruby on Rails
遇見 Ruby on Rails遇見 Ruby on Rails
遇見 Ruby on Rails
 
Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013Testing at-cloud-speed sans-app-sec-austin-2013
Testing at-cloud-speed sans-app-sec-austin-2013
 
Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03Aws Lambda for Java Architects - Illinois VJug -2016-05-03
Aws Lambda for Java Architects - Illinois VJug -2016-05-03
 
Hadoop Spark - Reuniao SouJava 12/04/2014
Hadoop Spark - Reuniao SouJava 12/04/2014Hadoop Spark - Reuniao SouJava 12/04/2014
Hadoop Spark - Reuniao SouJava 12/04/2014
 

Recently uploaded

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Writing quick and beautiful automation code

  • 1. Writing quick and beautiful automation code Introduction to Hamcrest and Lambdaj Cristian Coțoi May 20 2013
  • 2. •BDD (Agile) has new needs •What is hamcrest •What is lambdaj •Improvement Agenda 2
  • 3. IN YOUR ZONE Purpose 3 •http://hamcrest.org •“Hamcrest it is not a testing library: it just happens that matchers are very useful for testing.” •Matching allows writing of lines that are close-to natural language •Anagram of “matchers” •http://code.google.com/p/lambdaj/ •Access collections without explicit loops •Operations include: items filtering, converting, sorting, method invoking, concatenate etc. Hamcrest Lambdaj
  • 4. IN YOUR ZONE Why Hamcrest 4 •Clarity •assertThat(a, is(“3”)); •assertEquals(a, “3”); •Speed •Not necessarily applicable for isNull() or isNotNull() •assertThat(list, hasItems(“banana”, “paple”, “papoi”));
  • 5. IN YOUR ZONE Hamcrest (some of the common matchers) 5 •Core • is •Logical • allOf - like Java && • anyOf - like Java || • not •Object • equalTo - test object equality using Object.equals • notNullValue, nullValue - test for null
  • 6. IN YOUR ZONE Hamcrest (some of the common matchers) 6 •Collections • hasEntry, hasKey, hasValue - test a map contains an entry, key or value • hasItem, hasItems - test a collection contains elements •Number • closeTo - test floating point values are close to a given value • greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo - test ordering •Text • equalToIgnoringCase • containsString, endsWith, startsWith - test string matching
  • 8. IN YOUR ZONE Hamcrest Examples 8 •hasItem, hasItems
  • 9. IN YOUR ZONE Hamcrest examples 9 •hasItems (fail)
  • 10. IN YOUR ZONE Hamcrest examples 10 •hasEntry, hasValue, hasKey
  • 11. IN YOUR ZONE Hamcrest examples 11 •Numbers
  • 12. IN YOUR ZONE Hamcrest 12 •Actual automation code example
  • 13. IN YOUR ZONE Lambdaj 13 •It’s designed to easily manipulate collections. •It uses Hamcrest matchers for filtering
  • 14. IN YOUR ZONE Why Lambdaj 14 •Readability •Collections are very common •Iterating over them is not dead-easy •Loops are hard to read •Operations for collections: Convert, Index, Filter, Sort, Extract etc.
  • 15. IN YOUR ZONE Lambdaj examples 15 •Mathematical comparisons •Mathematical operations
  • 16. IN YOUR ZONE Lambdaj examples 16 •Method invoke – add last name
  • 17. IN YOUR ZONE Lambdaj examples 17 •Select
  • 18. IN YOUR ZONE Lambdaj examples 18 •Youngest Papoi
  • 19. IN YOUR ZONE Lambdaj automation example 19
  • 20. IN YOUR ZONE Lambdaj limitations 20 •Null or empty collection in forEach •Final class
  • 21. IN YOUR ZONE Benefits 21 •Integration with Agile methodologies (BDD) •Clarity •Speed •Quick learning curve •Extensive application
  • 22. IN YOUR ZONE Thank you 22 Cristian Coțoi| Senior Tester
  • 23. IN YOUR ZONE References 23 •Hamcrest • http://code.google.com/p/hamcrest/wiki/Tutorial • http://edgibbs.com/junit-4-with-hamcrest/ • http://rafaelnaufal.com/blog/2010/03/15/using-hamcrest-and-junit/ - writing your own matchers •LambdaJ • http://code.google.com/p/lambdaj/ • http://code.google.com/p/lambdaj/wiki/LambdajFeatures

Editor's Notes

  1. There is a new trend in BDD that empowers every member of the team to make changes in the code of the application & testing, starting with how the stories are connected with the code and should also be taken deeper.Hamcrest and lambdaj are 2 such libraries that make the code more human readable and easier to understand.
  2. So why would I want to write assertions like this?ClarityassertThat() is a replacement for the traditionalassertEqual that is focused more on specifications than on BDDFirst one reads: “assert that a is 3”. The second reads “assert equals a (and) 3”SpeedThis is pretty str8 forward: “assert that list contains ‘banana’, ‘paple’, ‘papoi’”
  3. Collections are hard to interrogate, especially when read from an outside source.It is easy to write a loop, but not so very easy to extract things from that loop or perform conversions or other operations on the items in the loop.
  4. You can read this like:select from family items having…last nameequal to `Papoi`
  5. The current implementation of forEach cannot handle null or empty collections – this will just throw an exception.The same is true for a final class that is used with on()On average it is about 2-3 times slower, but depending on the collection it sometimes can be 6 times slower.