SlideShare a Scribd company logo
Advanced testing techniques 
When assertThat(you).understandUnitTesting() fails 
23 October 2014 
Martin Škurla, Equities IT
Speaker’s Bio 
• Ing. Martin Škurla 
• Certifications 
• Sun Certified Programmer for the Java 2 Platform, Standard Edition 6.0 
• Oracle Certified Professional, Java EE 5 Web Component Developer 
• Open Source Committer 
• Gephi (GSoC 2010), NetBeans (NetCAT), Abego Tree Layout, AST Visualizer, 
Tyrus 
• Conference/JUG Speaker 
• Fosdem, CZJUG, GeeCON 
• Technical Reviewer 
• CPress, Grada, Manning 
• Previous work experience 
• Sors Technology, ESET, Celum, Atlassian 
• Currently 
• PSEC at Barclays 
2 | Advanced testing techniques | 23 October 2014 
COPYRIGHT © Copyright Barclays Bank PLC, 2014 (all rights reserved).
“More than the act of testing, the act of designing tests is one of the 
best bug preventers known. The thinking that must be done to create 
a useful test can discover and eliminate bugs before they are coded – 
indeed, test-design thinking can discover and eliminate bugs at every 
stage in the creation of software, from conception to specification, to 
design, coding and the rest.” [1] 
3 | Advanced testing techniques | 23 October 2014 
Boris Beizer 
[1] Software Testing Techniques, Creating a Software Engineering Culture by Karl Eugene Wiegers, ISBN: 0932633331 , Page: 211
Agenda 
• Test face-lifting 
• naming conventions 
• logical grouping 
• test code smells and “refactoring patterns” 
• bad practices and pitfalls 
• Custom assertions 
• Declarative and Data driven testing 
• Advanced techniques 
• TestNG framework integration 
• concurrent test execution 
• Results (code reduction, number of tests, execution time) 
4 | Advanced testing techniques | 23 October 2014
Naming conventions 
• The most important asset of a unit test is readability. 
• We try to achieve “readable tests” 
• readable vs. understandable tests 
• Test method naming conventions: 
• testNameOfTheMethod() antipattern 
• method name should contain 3 parts: behavior being tested, inputs and outputs 
• e.g. attrUsedInRules_ShouldNotBeAbleToRemove(), 
removingAttrUsedInRules_ShouldThrowIllegalArgumentException(), 
ruleEqualsAndHashCodeMethods_ShouldBeCorrectlyImplemented(), 
getAttrVal_ShouldThrowExceptionWhenAmbiguityHappens() 
• Test lifecycle method naming conventions: 
• setUp() & tearDown() antipatterns 
• e.g. @BeforeMethod public void rulesInit() {…} 
5 | Advanced testing techniques | 23 October 2014
Logical grouping 
• Don’t put all test code related to single class/method always into the 
same test class. 
• NameOfClassTest antipattern 
• it doesn’t scale for anything but trivial examples 
• Instead, you should group tests logically. 
• AE has attributes, attribute groups, cross rule validation, distinct rules, matching 
expressions, meta rules, querying API, rule ambiguities handling, rule precedence, 
target expressions, transactional behavior 
• e.g. AttrManipulationTest, AttributeEngineTest, AttrGroupTest, 
CrossRuleValidationTest, DistinctRuleTest, 
GettingAttrsRulesAndValsAPITest, MatchingAttrExpressionsTest, 
MetaRuleManipulationTest, MetaRulesTest, RuleAmbiguitiesTest, 
RuleManipulationTest, RuleMatchValsTest, RulePrecedenceTest, 
TargetAttrExpressionsTest, TransactionalBehaviorTest 
6 | Advanced testing techniques | 23 October 2014
Test code smells and “refactoring patterns” 
• Conditions 
• introducing multiple test execution paths is bad 
• => multiple tests, JUnit assumptions, TestNG SkipException 
• Loops 
• introducing multiple test cases into a single test is bad 
• => parameterized testing, more powerful (custom) assertions 
• Assertions on different objects 
• test should only assert on a single object: SUT 
• => refactoring to multiple tests 
• Multiple assignments into the same variable 
• reinitializing the SUT is bad 
• => refactoring to multiple tests 
7 | Advanced testing techniques | 23 October 2014
“Yesterday’s best practices is tomorrow’s anti-pattern.” [2] 
8 | Advanced testing techniques | 23 October 2014 
Neal Ford 
[2] GeeCON Prague 2014 Conference, This is water, Opening Keynote
Bad practices 
• Using assertTrue(), assertFalse(), assertEquals() 
• => use custom assertions 
• Sophisticated string assertion description 
• assertEquals(String message, Object expected, Object actual); 
• => use custom assertions 
• Logging and printing into console 
• => remove it 
• Boolean asserted aggregation 
• => rewrite to multiple tests 
• Sophisticated tests 
• GC tests, memory leak tests, latency tests 
• => remove them 
9 | Advanced testing techniques | 23 October 2014
Common pitfalls 
• Removing repetition 
• some level of repetition is actually good 
• => don’t do that 
• Introducing constants 
• test constants should only be introduced if the particular value is not important for test 
• => don’t introduce constants as in normal code 
• SUT initialization in @BeforeMethod 
• not conforming to arrange-act-assert 
• not directly obvious how SUT is initialized 
• introduces mutability (stay tuned) 
• => don’t initialize SUT in @BeforeMethod if not necessary 
• Reusing SUT 
• you might be relying on already modified state 
• => never reuse already used SUT 
10 | Advanced testing techniques | 23 October 2014
Agenda 
• Test face-lifting 
• naming conventions 
• logical grouping 
• test code smells and “refactoring patterns” 
• bad practices and pitfalls 
• Custom assertions 
• Declarative and Data driven testing 
• Advanced techniques 
• TestNG framework integration 
• concurrent test execution 
• Results (code reduction, number of tests, execution time) 
11 | Advanced testing techniques | 23 October 2014
Custom assertions 
• Because of readability 
• assertThatAttr(“T1”).hasDescription(“…”); 
• Very useful when API is leaking implementation details 
• e.g. returning complicated data structures 
• assertThatUnsuppressedRules(rules).containRulesOnLines(1, 2); 
assertThatSuppressedRules(rules).isNull(); 
• Very powerful when custom assertions reuse other custom assertions 
• assertThatException(e).forRuleOnLine(1).hasDependentCount(1) 
.forRuleOnLine(2).hasDependentCount(2); 
• Think twice before adding custom assertions. 
12 | Advanced testing techniques | 23 October 2014
Agenda 
• Test face-lifting 
• naming conventions 
• logical grouping 
• test code smells and “refactoring patterns” 
• bad practices and pitfalls 
• Custom assertions 
• Declarative and Data driven testing 
• Advanced techniques 
• TestNG framework integration 
• concurrent test execution 
• Results (code reduction, number of tests, execution time) 
13 | Advanced testing techniques | 23 October 2014
Declarative and Data driven testing 
• Data driven testing 
• testing the same code, but with different inputs and outputs 
• Declarative testing 
• tests are saying what to do and not how 
@DataProvider private String[][] attrGroupDataProvider() { 
return new String[][] {{“XETRA”, “b111”, “rule2”}};} 
@MatchingAttrDelimiter(“!”) 
@AeColumns(“M1 ! M2 || +M1 || T1 ”) 
@AeRules( {“LSE ! || EUROPE || ”, 
“+EUROPE” ! /a111 || || rule1”) 
@Test(dataProvider= “attrGroupDataProvider” ) 
public void attrGroup_...(String m1, String m2, String expT1) {} 
14 | Advanced testing techniques | 23 October 2014
Agenda 
• Test face-lifting 
• naming conventions 
• logical grouping 
• test code smells and “refactoring patterns” 
• bad practices and pitfalls 
• Custom assertions 
• Declarative and Data driven testing 
• Advanced techniques 
• TestNG framework integration 
• concurrent test execution 
• Results (code reduction, number of tests, execution time) 
15 | Advanced testing techniques | 23 October 2014
TestNG framework integration 
• TestNG listeners 
• for handling declarative testing 
• @AEColumns, @AEFileResources, @AERules, @MatchingAttrDelimiter, 
@MetaAEColumns, @MetaAERules, @TrimOnlyLeadingAndTrailingSpaces 
• listeners should play nicely with data providers 
• listeners should support concurrency 
• But how does it feel like to integrate into TestNG? 
• happiness followed by hacking3 
private static final Set<String> UGLY_HACK = new HashSet<String>(); 
• you have to expect issues 
• internal bugs (Maven surefire plug-in) 
• workarounds (ROCK-581) 
3 “to devise or modify (a computer program), usually skillfully” according to http://dictionary.reference.com/browse/hacking?s=t 
16 | Advanced testing techniques | 23 October 2014
Concurrent test execution 
• The point of adding concurrency into tests was surprisingly not 
performance. 
• the reason was the independence (isolation) 
• Different granularities 
• test suites, test classes, test methods 
• Achievable by removing all unnecessary and guarding the necessary 
shared state. 
• application of thread-safety and functional principles 
• Test framework integration 
• solid understanding of the testing framework thread model is essential 
• But what to do when thread-safety cannot be achieved? 
• @Test(singleThreaded = true) 
• JVM forking (last resort solution) 
17 | Advanced testing techniques | 23 October 2014
Agenda 
• Test face-lifting 
• naming conventions 
• logical grouping 
• test code smells and “refactoring patterns” 
• bad practices and pitfalls 
• Custom assertions 
• Declarative and Data driven testing 
• Advanced techniques 
• TestNG framework integration 
• concurrent test execution 
• Results (code reduction, number of tests, execution time) 
18 | Advanced testing techniques | 23 October 2014
Results 
• JIRA issues resolved: 
• specifically created: ROCK-349, ROCK-395, ROCK-396, ROCK-397, 
ROCK-481, ROCK-613 
• resolved as a side-effect of refactoring: ROCK-295 
• TestNG workarounds: ROCK-581 
• won’t fix: ROCK-511 
• introduced bug: ROCK-585 
• pending: ROCK-495 
• Testable documentation 
• This is in line with Barclay’s Values including Stewardship 
19 | Advanced testing techniques | 23 October 2014
Results 
40 
35 
30 
25 
20 
15 
10 
600 
550 
500 
450 
400 
350 
300 
250 
200 
150 
100 
Before ROCK-349 ROCK-397 ROCK-396 ROCK-395 ROCK-481 ROCK-613 
Number of tests Execution time (sec) 
65000 
60000 
55000 
50000 
45000 
40000 
35000 
30000 
550 
500 
450 
400 
350 
300 
Before ROCK-349 ROCK-397 ROCK-396 ROCK-395 ROCK-481 ROCK-613 
Test code size (kB) Test resources size (kB) 
• Number of tests: 
• 373.38% 
• Execution time: 
• 42.64% 
• Number of lines: 
• 61.57% 
• Test code size: 
• 63.99% 
• Test resources size: 
• 57.45% 
20 | Advanced testing techniques | 23 October 2014
More on testing libraries, books 
• Links4: 
• http://testng.org/doc/index.html 
• http://code.google.com/p/hamcrest/ 
• http://joel-costigliola.github.io/assertj/ 
• http://code.google.com/p/catch-exception/ 
• http://www.manning.com/koskela2/ 
• http://www.manning.com/osherove2/ 
4 These links were accessed on 23/09/2014. The websites are those of third parties and Barclays is not responsible for any information stated to be obtained 
or derived from these third party sources. 
21 | Advanced testing techniques | 23 October 2014
Q & A 
22 | Advanced testing techniques | 23 October 2014
23 | Advanced testing techniques | 23 October 2014
Thank you for your 
attention
Disclaimer 
CONFLICTS OF INTEREST BARCLAYS IS A FULL SERVICE INVESTMENT BANK. In the normal course of offering investment banking products and services to clients. 
Barclays may act in several capacities (including issuer, market maker, underwriter, distributor, index sponsor, swap counterparty and calculation agent) simultaneously with 
respect to a product, giving rise to potential conflicts of interest which may impact the performance of a product. 
NOT RESEARCH This document is from a Barclays Trading and/or Distribution desk and is not a product of the Barclays Research department. Any views expressed may 
differ from those of Barclays Research. 
BARCLAYS POSITIONS Barclays, its affiliates and associated personnel may at any time acquire, hold or dispose of long or short positions (including hedging and trading 
positions) which may impact the performance of a product. 
FOR INFORMATION ONLY THIS DOCUMENT IS PROVIDED FOR INFORMATION PURPOSES ONLY AND IT IS SUBJECT TO CHANGE. IT IS INDICATIVE ONLY AND IS 
NOT BINDING. 
NO OFFER Barclays is not offering to sell or seeking offers to buy any product or enter into any transaction. Any transaction requires Barclays’ subsequent formal agreement 
which will be subject to internal approvals and binding transaction documents. 
NO LIABILITY Barclays is not responsible for the use made of this document other than the purpose for which it is intended, except to the extent this would be prohibited by 
law or regulation. 
NO ADVICE OBTAIN INDEPENDENT PROFESSIONAL ADVICE BEFORE INVESTING OR TRANSACTING. Barclays is not an advisor and will not provide any advice 
relating to a product. Before making an investment decision, investors should ensure they have sufficient information to ascertain the legal, financial, tax and regulatory 
consequences of an investment to enable them to make an informed investment decision. 
THIRD PARTY INFORMATION Barclays is not responsible for information stated to be obtained or derived from third party sources or statistical services. 
PAST & SIMULATED PAST PERFORMANCE Any past or simulated past performance (including back-testing) contained herein is no indication as to future performance. 
OPINIONS SUBJECT TO CHANGE All opinions and estimates are given as of the date hereof and are subject to change. Barclays is not obliged to inform investors of any 
change to such opinions or estimates. 
NOT FOR RETAIL This document is being directed at persons who are professionals and is not intended for retail customer use. 
IMPORTANT DISCLOSURES For important regional disclosures you must read, click on the link relevant to your region. Please contact your Barclays representative if you 
are unable to access. 
EMEA EMEA Disclosures APAC APAC Disclosures U.S. US Disclosures 
IRS CIRCULAR 230 DISCLOSURE: Barclays does not provide tax advice. Please note that (i) any discussion of US tax matters contained in this communication (including any 
attachments) cannot be used by you for the purpose of avoiding tax penalties; (ii) this communication was written to support the promotion or marketing of the matters addressed 
herein; and (iii) you should seek advice based on your particular circumstances from an independent tax advisor. 
CONFIDENTIAL This document is confidential and no part of it may be reproduced, distributed or transmitted without the prior written permission of Barclays. 
ABOUT BARCLAYS Barclays Bank PLC offers premier investment banking products and services to its clients through Barclays Bank PLC. Barclays Bank PLC is authorised 
by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority and is a member of the London Stock Exchange. 
Barclays Bank PLC is registered in England No. 1026167 with its registered office at 1 Churchill Place, London E14 5HP. 
COPYRIGHT © Copyright Barclays Bank PLC, 2014 (all rights reserved). 
25 | Advanced testing techniques | 23 October 2014

More Related Content

What's hot

[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
ICS
 
Cpp unit
Cpp unit Cpp unit
Cpp unit
mudabbirwarsi
 
Test driven development
Test driven developmentTest driven development
Test driven development
christoforosnalmpantis
 
Junit
JunitJunit
Junit 4.0
Junit 4.0Junit 4.0
TDD Training
TDD TrainingTDD Training
TDD Training
Manuela Grindei
 
Automated Repair of Feature Interaction Failures in Automated Driving Systems
Automated Repair of Feature Interaction Failures in Automated Driving SystemsAutomated Repair of Feature Interaction Failures in Automated Driving Systems
Automated Repair of Feature Interaction Failures in Automated Driving Systems
Lionel Briand
 
CppUnit using introduction
CppUnit using introductionCppUnit using introduction
CppUnit using introduction
Iurii Kyian
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
liminescence
 
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, CesarOSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
mfrancis
 
xUnit Style Database Testing
xUnit Style Database TestingxUnit Style Database Testing
xUnit Style Database Testing
Chris Oldwood
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
Dror Helper
 
Next Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized TestingNext Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized Testing
Tao Xie
 
Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
atesgoral
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit Tests
John Ferguson Smart Limited
 
Need(le) for Speed - Effective Unit Testing for Java EE
Need(le) for Speed - Effective Unit Testing for Java EENeed(le) for Speed - Effective Unit Testing for Java EE
Need(le) for Speed - Effective Unit Testing for Java EE
hwilming
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
guy_davis
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
Abner Chih Yi Huang
 
STAMP Descartes Presentation
STAMP Descartes PresentationSTAMP Descartes Presentation
STAMP Descartes Presentation
STAMP Project
 

What's hot (20)

[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
Cpp unit
Cpp unit Cpp unit
Cpp unit
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Junit
JunitJunit
Junit
 
Junit 4.0
Junit 4.0Junit 4.0
Junit 4.0
 
TDD Training
TDD TrainingTDD Training
TDD Training
 
Automated Repair of Feature Interaction Failures in Automated Driving Systems
Automated Repair of Feature Interaction Failures in Automated Driving SystemsAutomated Repair of Feature Interaction Failures in Automated Driving Systems
Automated Repair of Feature Interaction Failures in Automated Driving Systems
 
CppUnit using introduction
CppUnit using introductionCppUnit using introduction
CppUnit using introduction
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, CesarOSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
 
xUnit Style Database Testing
xUnit Style Database TestingxUnit Style Database Testing
xUnit Style Database Testing
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Next Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized TestingNext Generation Developer Testing: Parameterized Testing
Next Generation Developer Testing: Parameterized Testing
 
Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
 
JUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit TestsJUnit Kung Fu: Getting More Out of Your Unit Tests
JUnit Kung Fu: Getting More Out of Your Unit Tests
 
Need(le) for Speed - Effective Unit Testing for Java EE
Need(le) for Speed - Effective Unit Testing for Java EENeed(le) for Speed - Effective Unit Testing for Java EE
Need(le) for Speed - Effective Unit Testing for Java EE
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 
STAMP Descartes Presentation
STAMP Descartes PresentationSTAMP Descartes Presentation
STAMP Descartes Presentation
 

Similar to When assertthat(you).understandUnitTesting() fails

Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
aragozin
 
C++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ LondonC++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ London
Clare Macrae
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
Ortus Solutions, Corp
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
Andrey Oleynik
 
Technical Lessons Learned Turning the Agile Dials to Eleven!
Technical Lessons Learned Turning the Agile Dials to Eleven!Technical Lessons Learned Turning the Agile Dials to Eleven!
Technical Lessons Learned Turning the Agile Dials to Eleven!
Craig Smith
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
Devvrat Shukla
 
Ch11lect1 ud
Ch11lect1 udCh11lect1 ud
Ch11lect1 ud
Ahmet Balkan
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and Challenges
TriTAUG
 
Ivan Pashko - Simplifying test automation with design patterns
Ivan Pashko - Simplifying test automation with design patternsIvan Pashko - Simplifying test automation with design patterns
Ivan Pashko - Simplifying test automation with design patterns
Ievgenii Katsan
 
SledgehammerToFinebrush_Devnexus_2021
SledgehammerToFinebrush_Devnexus_2021SledgehammerToFinebrush_Devnexus_2021
SledgehammerToFinebrush_Devnexus_2021
Shelley Lambert
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
Roman Okolovich
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
Jay Friendly
 
Unit testing
Unit testingUnit testing
Unit testing
Vinod Wilson
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep Learning
Shelley Lambert
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
Meilan Ou
 
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
NaviAningi
 
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.pptKKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
Kiran Kumar SD
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
Steven Li
 
Unit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step TrainingUnit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step Training
Ram Awadh Prasad, PMP
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
ICS
 

Similar to When assertthat(you).understandUnitTesting() fails (20)

Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 
C++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ LondonC++ Testing Techniques Tips and Tricks - C++ London
C++ Testing Techniques Tips and Tricks - C++ London
 
Into The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applicationsInto The Box 2018 | Assert control over your legacy applications
Into The Box 2018 | Assert control over your legacy applications
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
 
Technical Lessons Learned Turning the Agile Dials to Eleven!
Technical Lessons Learned Turning the Agile Dials to Eleven!Technical Lessons Learned Turning the Agile Dials to Eleven!
Technical Lessons Learned Turning the Agile Dials to Eleven!
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Ch11lect1 ud
Ch11lect1 udCh11lect1 ud
Ch11lect1 ud
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and Challenges
 
Ivan Pashko - Simplifying test automation with design patterns
Ivan Pashko - Simplifying test automation with design patternsIvan Pashko - Simplifying test automation with design patterns
Ivan Pashko - Simplifying test automation with design patterns
 
SledgehammerToFinebrush_Devnexus_2021
SledgehammerToFinebrush_Devnexus_2021SledgehammerToFinebrush_Devnexus_2021
SledgehammerToFinebrush_Devnexus_2021
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
 
Unit testing
Unit testingUnit testing
Unit testing
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep Learning
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
 
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.pptKKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
 
Unit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step TrainingUnit Testng with PHP Unit - A Step by Step Training
Unit Testng with PHP Unit - A Step by Step Training
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 

More from Martin Skurla

2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
Martin Skurla
 
2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf
Martin Skurla
 
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
Martin Skurla
 
Exploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical DilemmasExploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical Dilemmas
Martin Skurla
 
Interpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis PsychotherapyInterpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis Psychotherapy
Martin Skurla
 
ESET 3 internship protocol
ESET 3 internship protocolESET 3 internship protocol
ESET 3 internship protocol
Martin Skurla
 
Mastering Redecision Therapy
Mastering Redecision TherapyMastering Redecision Therapy
Mastering Redecision Therapy
Martin Skurla
 
Life Script
Life ScriptLife Script
Life Script
Martin Skurla
 
The Vital Skill of Clinical Assessment
The Vital Skill of Clinical AssessmentThe Vital Skill of Clinical Assessment
The Vital Skill of Clinical Assessment
Martin Skurla
 
Psychotherapy from the clients perspective
Psychotherapy from the clients perspectivePsychotherapy from the clients perspective
Psychotherapy from the clients perspective
Martin Skurla
 
There's No Place Like Home
There's No Place Like HomeThere's No Place Like Home
There's No Place Like Home
Martin Skurla
 
Advanced Counselling Skills
Advanced Counselling SkillsAdvanced Counselling Skills
Advanced Counselling Skills
Martin Skurla
 
CATA conference 2023.pdf
CATA conference 2023.pdfCATA conference 2023.pdf
CATA conference 2023.pdf
Martin Skurla
 
UKATA Conference 2023
UKATA Conference 2023UKATA Conference 2023
UKATA Conference 2023
Martin Skurla
 
Applied TA in clinical practice
Applied TA in clinical practiceApplied TA in clinical practice
Applied TA in clinical practice
Martin Skurla
 
Intensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cardsIntensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cards
Martin Skurla
 
Personality Focused Treatment
Personality Focused TreatmentPersonality Focused Treatment
Personality Focused Treatment
Martin Skurla
 
Advanced training in Transanctional analysis
Advanced training in Transanctional analysisAdvanced training in Transanctional analysis
Advanced training in Transanctional analysis
Martin Skurla
 
Magdalena internship protocol
Magdalena internship protocolMagdalena internship protocol
Magdalena internship protocol
Martin Skurla
 
PPP internship protocol
PPP internship protocolPPP internship protocol
PPP internship protocol
Martin Skurla
 

More from Martin Skurla (20)

2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
 
2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf
 
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
 
Exploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical DilemmasExploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical Dilemmas
 
Interpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis PsychotherapyInterpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis Psychotherapy
 
ESET 3 internship protocol
ESET 3 internship protocolESET 3 internship protocol
ESET 3 internship protocol
 
Mastering Redecision Therapy
Mastering Redecision TherapyMastering Redecision Therapy
Mastering Redecision Therapy
 
Life Script
Life ScriptLife Script
Life Script
 
The Vital Skill of Clinical Assessment
The Vital Skill of Clinical AssessmentThe Vital Skill of Clinical Assessment
The Vital Skill of Clinical Assessment
 
Psychotherapy from the clients perspective
Psychotherapy from the clients perspectivePsychotherapy from the clients perspective
Psychotherapy from the clients perspective
 
There's No Place Like Home
There's No Place Like HomeThere's No Place Like Home
There's No Place Like Home
 
Advanced Counselling Skills
Advanced Counselling SkillsAdvanced Counselling Skills
Advanced Counselling Skills
 
CATA conference 2023.pdf
CATA conference 2023.pdfCATA conference 2023.pdf
CATA conference 2023.pdf
 
UKATA Conference 2023
UKATA Conference 2023UKATA Conference 2023
UKATA Conference 2023
 
Applied TA in clinical practice
Applied TA in clinical practiceApplied TA in clinical practice
Applied TA in clinical practice
 
Intensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cardsIntensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cards
 
Personality Focused Treatment
Personality Focused TreatmentPersonality Focused Treatment
Personality Focused Treatment
 
Advanced training in Transanctional analysis
Advanced training in Transanctional analysisAdvanced training in Transanctional analysis
Advanced training in Transanctional analysis
 
Magdalena internship protocol
Magdalena internship protocolMagdalena internship protocol
Magdalena internship protocol
 
PPP internship protocol
PPP internship protocolPPP internship protocol
PPP internship protocol
 

Recently uploaded

"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
ScyllaDB
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
Sunil Jagani
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
Ortus Solutions, Corp
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 

Recently uploaded (20)

"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!Introducing BoxLang : A new JVM language for productivity and modularity!
Introducing BoxLang : A new JVM language for productivity and modularity!
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 

When assertthat(you).understandUnitTesting() fails

  • 1. Advanced testing techniques When assertThat(you).understandUnitTesting() fails 23 October 2014 Martin Škurla, Equities IT
  • 2. Speaker’s Bio • Ing. Martin Škurla • Certifications • Sun Certified Programmer for the Java 2 Platform, Standard Edition 6.0 • Oracle Certified Professional, Java EE 5 Web Component Developer • Open Source Committer • Gephi (GSoC 2010), NetBeans (NetCAT), Abego Tree Layout, AST Visualizer, Tyrus • Conference/JUG Speaker • Fosdem, CZJUG, GeeCON • Technical Reviewer • CPress, Grada, Manning • Previous work experience • Sors Technology, ESET, Celum, Atlassian • Currently • PSEC at Barclays 2 | Advanced testing techniques | 23 October 2014 COPYRIGHT © Copyright Barclays Bank PLC, 2014 (all rights reserved).
  • 3. “More than the act of testing, the act of designing tests is one of the best bug preventers known. The thinking that must be done to create a useful test can discover and eliminate bugs before they are coded – indeed, test-design thinking can discover and eliminate bugs at every stage in the creation of software, from conception to specification, to design, coding and the rest.” [1] 3 | Advanced testing techniques | 23 October 2014 Boris Beizer [1] Software Testing Techniques, Creating a Software Engineering Culture by Karl Eugene Wiegers, ISBN: 0932633331 , Page: 211
  • 4. Agenda • Test face-lifting • naming conventions • logical grouping • test code smells and “refactoring patterns” • bad practices and pitfalls • Custom assertions • Declarative and Data driven testing • Advanced techniques • TestNG framework integration • concurrent test execution • Results (code reduction, number of tests, execution time) 4 | Advanced testing techniques | 23 October 2014
  • 5. Naming conventions • The most important asset of a unit test is readability. • We try to achieve “readable tests” • readable vs. understandable tests • Test method naming conventions: • testNameOfTheMethod() antipattern • method name should contain 3 parts: behavior being tested, inputs and outputs • e.g. attrUsedInRules_ShouldNotBeAbleToRemove(), removingAttrUsedInRules_ShouldThrowIllegalArgumentException(), ruleEqualsAndHashCodeMethods_ShouldBeCorrectlyImplemented(), getAttrVal_ShouldThrowExceptionWhenAmbiguityHappens() • Test lifecycle method naming conventions: • setUp() & tearDown() antipatterns • e.g. @BeforeMethod public void rulesInit() {…} 5 | Advanced testing techniques | 23 October 2014
  • 6. Logical grouping • Don’t put all test code related to single class/method always into the same test class. • NameOfClassTest antipattern • it doesn’t scale for anything but trivial examples • Instead, you should group tests logically. • AE has attributes, attribute groups, cross rule validation, distinct rules, matching expressions, meta rules, querying API, rule ambiguities handling, rule precedence, target expressions, transactional behavior • e.g. AttrManipulationTest, AttributeEngineTest, AttrGroupTest, CrossRuleValidationTest, DistinctRuleTest, GettingAttrsRulesAndValsAPITest, MatchingAttrExpressionsTest, MetaRuleManipulationTest, MetaRulesTest, RuleAmbiguitiesTest, RuleManipulationTest, RuleMatchValsTest, RulePrecedenceTest, TargetAttrExpressionsTest, TransactionalBehaviorTest 6 | Advanced testing techniques | 23 October 2014
  • 7. Test code smells and “refactoring patterns” • Conditions • introducing multiple test execution paths is bad • => multiple tests, JUnit assumptions, TestNG SkipException • Loops • introducing multiple test cases into a single test is bad • => parameterized testing, more powerful (custom) assertions • Assertions on different objects • test should only assert on a single object: SUT • => refactoring to multiple tests • Multiple assignments into the same variable • reinitializing the SUT is bad • => refactoring to multiple tests 7 | Advanced testing techniques | 23 October 2014
  • 8. “Yesterday’s best practices is tomorrow’s anti-pattern.” [2] 8 | Advanced testing techniques | 23 October 2014 Neal Ford [2] GeeCON Prague 2014 Conference, This is water, Opening Keynote
  • 9. Bad practices • Using assertTrue(), assertFalse(), assertEquals() • => use custom assertions • Sophisticated string assertion description • assertEquals(String message, Object expected, Object actual); • => use custom assertions • Logging and printing into console • => remove it • Boolean asserted aggregation • => rewrite to multiple tests • Sophisticated tests • GC tests, memory leak tests, latency tests • => remove them 9 | Advanced testing techniques | 23 October 2014
  • 10. Common pitfalls • Removing repetition • some level of repetition is actually good • => don’t do that • Introducing constants • test constants should only be introduced if the particular value is not important for test • => don’t introduce constants as in normal code • SUT initialization in @BeforeMethod • not conforming to arrange-act-assert • not directly obvious how SUT is initialized • introduces mutability (stay tuned) • => don’t initialize SUT in @BeforeMethod if not necessary • Reusing SUT • you might be relying on already modified state • => never reuse already used SUT 10 | Advanced testing techniques | 23 October 2014
  • 11. Agenda • Test face-lifting • naming conventions • logical grouping • test code smells and “refactoring patterns” • bad practices and pitfalls • Custom assertions • Declarative and Data driven testing • Advanced techniques • TestNG framework integration • concurrent test execution • Results (code reduction, number of tests, execution time) 11 | Advanced testing techniques | 23 October 2014
  • 12. Custom assertions • Because of readability • assertThatAttr(“T1”).hasDescription(“…”); • Very useful when API is leaking implementation details • e.g. returning complicated data structures • assertThatUnsuppressedRules(rules).containRulesOnLines(1, 2); assertThatSuppressedRules(rules).isNull(); • Very powerful when custom assertions reuse other custom assertions • assertThatException(e).forRuleOnLine(1).hasDependentCount(1) .forRuleOnLine(2).hasDependentCount(2); • Think twice before adding custom assertions. 12 | Advanced testing techniques | 23 October 2014
  • 13. Agenda • Test face-lifting • naming conventions • logical grouping • test code smells and “refactoring patterns” • bad practices and pitfalls • Custom assertions • Declarative and Data driven testing • Advanced techniques • TestNG framework integration • concurrent test execution • Results (code reduction, number of tests, execution time) 13 | Advanced testing techniques | 23 October 2014
  • 14. Declarative and Data driven testing • Data driven testing • testing the same code, but with different inputs and outputs • Declarative testing • tests are saying what to do and not how @DataProvider private String[][] attrGroupDataProvider() { return new String[][] {{“XETRA”, “b111”, “rule2”}};} @MatchingAttrDelimiter(“!”) @AeColumns(“M1 ! M2 || +M1 || T1 ”) @AeRules( {“LSE ! || EUROPE || ”, “+EUROPE” ! /a111 || || rule1”) @Test(dataProvider= “attrGroupDataProvider” ) public void attrGroup_...(String m1, String m2, String expT1) {} 14 | Advanced testing techniques | 23 October 2014
  • 15. Agenda • Test face-lifting • naming conventions • logical grouping • test code smells and “refactoring patterns” • bad practices and pitfalls • Custom assertions • Declarative and Data driven testing • Advanced techniques • TestNG framework integration • concurrent test execution • Results (code reduction, number of tests, execution time) 15 | Advanced testing techniques | 23 October 2014
  • 16. TestNG framework integration • TestNG listeners • for handling declarative testing • @AEColumns, @AEFileResources, @AERules, @MatchingAttrDelimiter, @MetaAEColumns, @MetaAERules, @TrimOnlyLeadingAndTrailingSpaces • listeners should play nicely with data providers • listeners should support concurrency • But how does it feel like to integrate into TestNG? • happiness followed by hacking3 private static final Set<String> UGLY_HACK = new HashSet<String>(); • you have to expect issues • internal bugs (Maven surefire plug-in) • workarounds (ROCK-581) 3 “to devise or modify (a computer program), usually skillfully” according to http://dictionary.reference.com/browse/hacking?s=t 16 | Advanced testing techniques | 23 October 2014
  • 17. Concurrent test execution • The point of adding concurrency into tests was surprisingly not performance. • the reason was the independence (isolation) • Different granularities • test suites, test classes, test methods • Achievable by removing all unnecessary and guarding the necessary shared state. • application of thread-safety and functional principles • Test framework integration • solid understanding of the testing framework thread model is essential • But what to do when thread-safety cannot be achieved? • @Test(singleThreaded = true) • JVM forking (last resort solution) 17 | Advanced testing techniques | 23 October 2014
  • 18. Agenda • Test face-lifting • naming conventions • logical grouping • test code smells and “refactoring patterns” • bad practices and pitfalls • Custom assertions • Declarative and Data driven testing • Advanced techniques • TestNG framework integration • concurrent test execution • Results (code reduction, number of tests, execution time) 18 | Advanced testing techniques | 23 October 2014
  • 19. Results • JIRA issues resolved: • specifically created: ROCK-349, ROCK-395, ROCK-396, ROCK-397, ROCK-481, ROCK-613 • resolved as a side-effect of refactoring: ROCK-295 • TestNG workarounds: ROCK-581 • won’t fix: ROCK-511 • introduced bug: ROCK-585 • pending: ROCK-495 • Testable documentation • This is in line with Barclay’s Values including Stewardship 19 | Advanced testing techniques | 23 October 2014
  • 20. Results 40 35 30 25 20 15 10 600 550 500 450 400 350 300 250 200 150 100 Before ROCK-349 ROCK-397 ROCK-396 ROCK-395 ROCK-481 ROCK-613 Number of tests Execution time (sec) 65000 60000 55000 50000 45000 40000 35000 30000 550 500 450 400 350 300 Before ROCK-349 ROCK-397 ROCK-396 ROCK-395 ROCK-481 ROCK-613 Test code size (kB) Test resources size (kB) • Number of tests: • 373.38% • Execution time: • 42.64% • Number of lines: • 61.57% • Test code size: • 63.99% • Test resources size: • 57.45% 20 | Advanced testing techniques | 23 October 2014
  • 21. More on testing libraries, books • Links4: • http://testng.org/doc/index.html • http://code.google.com/p/hamcrest/ • http://joel-costigliola.github.io/assertj/ • http://code.google.com/p/catch-exception/ • http://www.manning.com/koskela2/ • http://www.manning.com/osherove2/ 4 These links were accessed on 23/09/2014. The websites are those of third parties and Barclays is not responsible for any information stated to be obtained or derived from these third party sources. 21 | Advanced testing techniques | 23 October 2014
  • 22. Q & A 22 | Advanced testing techniques | 23 October 2014
  • 23. 23 | Advanced testing techniques | 23 October 2014
  • 24. Thank you for your attention
  • 25. Disclaimer CONFLICTS OF INTEREST BARCLAYS IS A FULL SERVICE INVESTMENT BANK. In the normal course of offering investment banking products and services to clients. Barclays may act in several capacities (including issuer, market maker, underwriter, distributor, index sponsor, swap counterparty and calculation agent) simultaneously with respect to a product, giving rise to potential conflicts of interest which may impact the performance of a product. NOT RESEARCH This document is from a Barclays Trading and/or Distribution desk and is not a product of the Barclays Research department. Any views expressed may differ from those of Barclays Research. BARCLAYS POSITIONS Barclays, its affiliates and associated personnel may at any time acquire, hold or dispose of long or short positions (including hedging and trading positions) which may impact the performance of a product. FOR INFORMATION ONLY THIS DOCUMENT IS PROVIDED FOR INFORMATION PURPOSES ONLY AND IT IS SUBJECT TO CHANGE. IT IS INDICATIVE ONLY AND IS NOT BINDING. NO OFFER Barclays is not offering to sell or seeking offers to buy any product or enter into any transaction. Any transaction requires Barclays’ subsequent formal agreement which will be subject to internal approvals and binding transaction documents. NO LIABILITY Barclays is not responsible for the use made of this document other than the purpose for which it is intended, except to the extent this would be prohibited by law or regulation. NO ADVICE OBTAIN INDEPENDENT PROFESSIONAL ADVICE BEFORE INVESTING OR TRANSACTING. Barclays is not an advisor and will not provide any advice relating to a product. Before making an investment decision, investors should ensure they have sufficient information to ascertain the legal, financial, tax and regulatory consequences of an investment to enable them to make an informed investment decision. THIRD PARTY INFORMATION Barclays is not responsible for information stated to be obtained or derived from third party sources or statistical services. PAST & SIMULATED PAST PERFORMANCE Any past or simulated past performance (including back-testing) contained herein is no indication as to future performance. OPINIONS SUBJECT TO CHANGE All opinions and estimates are given as of the date hereof and are subject to change. Barclays is not obliged to inform investors of any change to such opinions or estimates. NOT FOR RETAIL This document is being directed at persons who are professionals and is not intended for retail customer use. IMPORTANT DISCLOSURES For important regional disclosures you must read, click on the link relevant to your region. Please contact your Barclays representative if you are unable to access. EMEA EMEA Disclosures APAC APAC Disclosures U.S. US Disclosures IRS CIRCULAR 230 DISCLOSURE: Barclays does not provide tax advice. Please note that (i) any discussion of US tax matters contained in this communication (including any attachments) cannot be used by you for the purpose of avoiding tax penalties; (ii) this communication was written to support the promotion or marketing of the matters addressed herein; and (iii) you should seek advice based on your particular circumstances from an independent tax advisor. CONFIDENTIAL This document is confidential and no part of it may be reproduced, distributed or transmitted without the prior written permission of Barclays. ABOUT BARCLAYS Barclays Bank PLC offers premier investment banking products and services to its clients through Barclays Bank PLC. Barclays Bank PLC is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority and is a member of the London Stock Exchange. Barclays Bank PLC is registered in England No. 1026167 with its registered office at 1 Churchill Place, London E14 5HP. COPYRIGHT © Copyright Barclays Bank PLC, 2014 (all rights reserved). 25 | Advanced testing techniques | 23 October 2014

Editor's Notes

  1. 0-5 min
  2. 5-10 min
  3. 10-15 min
  4. 15-20 min
  5. 20-25 min
  6. 25-30 min
  7. 0-5 min
  8. 30-35 min
  9. 0-5 min
  10. 35-40 min
  11. 0-5 min
  12. 40-45 min
  13. 45-50 min
  14. 0-5 min