SlideShare a Scribd company logo
1 of 25
Cork Software Crafters
Follow us on
Twitter: @CorkSwCraft
Meetup: www.meetup.com/Cork-Software-Craftsmanship-Meetup
Slack: softwarecrafters.slack.com/messages/cork
Approval Testing & Mutation Testing
25th June 2019, Cork
by Paulo Clavijo (@pclavijo)
Thanks
Join Software Crafters on Slack.
http://slack.softwarecrafters.org
#cork
We are always looking for new ideas, new talks and
mostly new hands-on sessions for our meetups.
Contact us if you want to collaborate!
6:15pm - Approval Testing and Mutation Testing introduction.
7:00pm - Hands-on time.
7:45pm - Retrospective
Paulo Clavijo (@pclavijo)
Agenda
Cork Software Crafters
Working with Legacy Code
Paulo Clavijo @pclavijo
Cork Software Crafters
Refactoring
Paulo Clavijo (@pclavijo)Cork Software Crafters
Refactoring
What? Restructuring code without changing its external behaviour.
Why? To make the code easier to change.
Paulo Clavijo @pclavijo
“Refactoring changes the programs in small steps. If you make a
mistake, it is easy to find the bug.” - Martin Fowler
“Refactoring is the choreography we use to move code from design
A to design B in a safe and efficient way” - Pedro Moreira Santos
Cork Software Crafters
Characterization Tests
Paulo Clavijo @pclavijo
Cork Software Crafters
“A characterization test (aka Golden Master Testing) is a means to describe the actual
behavior of an existing piece of software, and therefore protect existing behavior of
legacy code against unintended changes.” - Wikipedia
● Tests to enable refactoring.
● Protects existing behaviour.
● Often used with legacy untested code.
● Quickly results in high coverage.
Paulo Clavijo (@pclavijo)
Characterization Tests
Cork Software Crafters
Paulo Clavijo (@pclavijo)
Characterization Tests
Cork Software Crafters
Legacy code can be hard to test, we need to be creative writing our characterization tests
and make use of any output available. Think not just in responses from methods or APIs
also in other existing side-effects like logging statements, writes to databases, etc.
Approval TestS
Paulo Clavijo @pclavijo
Cork Software Crafters
A test technique which compares the current output of your code with an "approved"
version. The approved version is created by initially examining the output of your code by
hand and approving the result. You can revisit the approved version and easily update it
when the requirements change.
Paulo Clavijo (@pclavijo)
Approval Tests
Cork Software Crafters
Don’t Tell Me ...
Show Me!
Paulo Clavijo (@pclavijo)Cork Software Crafters
Paulo Clavijo (@pclavijo)
Approval Tests
Cork Software Crafters
public class GreeterTest {
@Test
public void should_say_hello() {
// Arrange
Greeter greeter = new Greeter("John Doe");
// Act
String greeting = greeter.sayHello();
// Assert
assertThat(greeting).isEqualTo("Hello, John Doe!");
}
}
public class GreeterTest {
@Test
public void should_say_hello() {
// Arrange
Greeter greeter = new Greeter("John Doe");
// Act
String greeting = greeter.sayHello();
// Verify output against approved
Approvals.verify(greeting);
}
}
Assertion-based test Approval test
Tracing Coverage
Tracing mode enables accurate collection of the branch coverage, with the ability to track tests,
view coverage statistic, and get additional information on each covered line.
Mutation Testing
Paulo Clavijo @pclavijo
Cork Software Crafters
Coverage is a useful tool to find untested code.
Coverage is of little use as a numeric statement of how good your tests are.
The problem is that a high coverage can be easily achive with low quality tests.
● 100% coverage with a single test
● 100% coverage with tests without assertions
Paulo Clavijo @pclavijo
Tests focused on the implementation instead of
behaviours and business rules.
Cork Software Crafters
Coverage != Tests Quality
Mutation Testing can be a powerful technique to evaluate the quality of your unit tests.
Experiment with small manual mutations in the production code and verify if the tests
fail.
if (a && b ) {
…
}
if (a || b ) {
…
}
Paulo Clavijo @pclavijo
Cork Software Crafters
Mutation Testing
Automated Mutation Testing tools
Paulo Clavijo @pclavijo
Cork Software Crafters
Mutant for Ruby
Infection for PHP
MutMut for Python
...
for JS, TS, C# and Scalafor Java
Mutation Testing
Mutation Testing
Paulo Clavijo @pclavijo
Cork Software Crafters
Don’t Tell Me ...
Show Me!
Paulo Clavijo (@pclavijo)Cork Software Crafters
Practice TIME
Paulo Clavijo (@pclavijo)Cork Software Crafters
Gilded Rose Kata
Your task is to add the new feature to our system so that we can begin selling a new
category of items.
● "Conjured" items degrade in Quality twice as fast as normal items
Feel free to make any changes to the UpdateQuality method and add any new code as
long as everything still works correctly. However, do not alter the Item class or Items
property.
github.com/Cork-Software-Craftsmanship-Community/GildedRose_Refactoring_Kata
https://github.com/emilybache/GildedRose-Refactoring-Kata
Cork Software Crafters Paulo Clavijo (@pclavijo)
Some advice
- Find the most idented piece of logic and start refactoring from the right.
- Try flattening conditional logic.
- A if statement can be removed if we add it to each of is nested statements.
- Remove inverted logic on conditional predicates.
- Make conditionals similar. Split conditionals (we will duplicate code during
some steps).
Cork Software Crafters Paulo Clavijo (@pclavijo)
Retrospective
● What went well?
● What problems did you encounter?
● What have you learned?
● What surprised you?
Paulo Clavijo (@pclavijo)Cork Software Crafters

More Related Content

What's hot

CodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passCodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passIlya Ghirici
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testingsjmarsh
 
Feedback en continu grâce au TDD et au AsCode
Feedback en continu grâce au TDD et au AsCodeFeedback en continu grâce au TDD et au AsCode
Feedback en continu grâce au TDD et au AsCodeHaja R
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Robin O'Brien
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018Paulo Clavijo
 
Asynchronous programming with Functional Java and comparison with Scala
Asynchronous programming with Functional Java and comparison with ScalaAsynchronous programming with Functional Java and comparison with Scala
Asynchronous programming with Functional Java and comparison with ScalaKnoldus Inc.
 
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana MandziukFwdays
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...ESUG
 
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...apidays
 
Let’s template
Let’s templateLet’s template
Let’s templateAllenKao7
 
AngularJs in Las Palmas de GC
AngularJs in Las Palmas de GCAngularJs in Las Palmas de GC
AngularJs in Las Palmas de GCMarcin Wosinek
 
Contract testing and Pact
Contract testing and PactContract testing and Pact
Contract testing and PactSeb Rose
 

What's hot (20)

Code Contracts
Code ContractsCode Contracts
Code Contracts
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
 
Cqrs
CqrsCqrs
Cqrs
 
CodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passCodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not pass
 
Contract based testing
Contract based testingContract based testing
Contract based testing
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testing
 
Let's Graph
Let's GraphLet's Graph
Let's Graph
 
Feedback en continu grâce au TDD et au AsCode
Feedback en continu grâce au TDD et au AsCodeFeedback en continu grâce au TDD et au AsCode
Feedback en continu grâce au TDD et au AsCode
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018TDD and Simple Design Workshop - Session 1 - November 2018
TDD and Simple Design Workshop - Session 1 - November 2018
 
Asynchronous programming with Functional Java and comparison with Scala
Asynchronous programming with Functional Java and comparison with ScalaAsynchronous programming with Functional Java and comparison with Scala
Asynchronous programming with Functional Java and comparison with Scala
 
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
 
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
Towards Modularity in Live Visual Modeling: A case-study with OpenPonk and Ke...
 
Testing in go
Testing in goTesting in go
Testing in go
 
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...
APIdays Paris 2018 - Client Library Automation, Inside Out, Avital Tzubeli, D...
 
Let’s template
Let’s templateLet’s template
Let’s template
 
AngularJs in Las Palmas de GC
AngularJs in Las Palmas de GCAngularJs in Las Palmas de GC
AngularJs in Las Palmas de GC
 
Contract testing and Pact
Contract testing and PactContract testing and Pact
Contract testing and Pact
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 

Similar to Approval Testing & Mutation Testing - Cork Software Crafters - June 2019

Tracking and improving software quality with SonarQube
Tracking and improving software quality with SonarQubeTracking and improving software quality with SonarQube
Tracking and improving software quality with SonarQubePatroklos Papapetrou (Pat)
 
A journey to_be_a_software_craftsman
A journey to_be_a_software_craftsmanA journey to_be_a_software_craftsman
A journey to_be_a_software_craftsmanJaehoon Oh
 
Lean engineering for lean/balanced teams: lessons learned (and still learning...
Lean engineering for lean/balanced teams: lessons learned (and still learning...Lean engineering for lean/balanced teams: lessons learned (and still learning...
Lean engineering for lean/balanced teams: lessons learned (and still learning...Balanced Team
 
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Sauce Labs
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog ArtifactoryTsuyoshi Miyake
 
Tested and Correct, How to Make Sure Your Documentation Keeps Working
Tested and Correct, How to Make Sure Your Documentation Keeps WorkingTested and Correct, How to Make Sure Your Documentation Keeps Working
Tested and Correct, How to Make Sure Your Documentation Keeps WorkingAdam Dangoor
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in ActionBill Scott
 
Reducing passive interruptions
Reducing passive interruptionsReducing passive interruptions
Reducing passive interruptionsAndrei Tognolo
 
How to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltHow to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltBrett Tramposh
 
Innovation Academy: Coding 101
Innovation Academy: Coding 101Innovation Academy: Coding 101
Innovation Academy: Coding 101Annamarie Carlson
 
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios
 
Kanban for Software Development and Kaizen Culture
Kanban for Software Development and Kaizen CultureKanban for Software Development and Kaizen Culture
Kanban for Software Development and Kaizen CultureAcquate
 
All levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-appsAll levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-appsAndrii Skrypnychenko
 
Continous Delivery Toronto Presentation
Continous Delivery Toronto PresentationContinous Delivery Toronto Presentation
Continous Delivery Toronto PresentationXebiaLabs
 
How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?Jonathan Jalouzot
 
DevOps/Flow workshop for agile india 2015
DevOps/Flow workshop for agile india 2015DevOps/Flow workshop for agile india 2015
DevOps/Flow workshop for agile india 2015Yuval Yeret
 

Similar to Approval Testing & Mutation Testing - Cork Software Crafters - June 2019 (20)

Tracking and improving software quality with SonarQube
Tracking and improving software quality with SonarQubeTracking and improving software quality with SonarQube
Tracking and improving software quality with SonarQube
 
A journey to_be_a_software_craftsman
A journey to_be_a_software_craftsmanA journey to_be_a_software_craftsman
A journey to_be_a_software_craftsman
 
Lean engineering for lean/balanced teams: lessons learned (and still learning...
Lean engineering for lean/balanced teams: lessons learned (and still learning...Lean engineering for lean/balanced teams: lessons learned (and still learning...
Lean engineering for lean/balanced teams: lessons learned (and still learning...
 
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
Tests for Every Branch Using CircleCI and Sauce Labs to Continuously Test CS ...
 
Enabling Lean at Enterprise Scale: Lean Engineering in Action
Enabling Lean at Enterprise Scale: Lean Engineering in ActionEnabling Lean at Enterprise Scale: Lean Engineering in Action
Enabling Lean at Enterprise Scale: Lean Engineering in Action
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
 
Tested and Correct, How to Make Sure Your Documentation Keeps Working
Tested and Correct, How to Make Sure Your Documentation Keeps WorkingTested and Correct, How to Make Sure Your Documentation Keeps Working
Tested and Correct, How to Make Sure Your Documentation Keeps Working
 
Hardening
HardeningHardening
Hardening
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
 
Reducing passive interruptions
Reducing passive interruptionsReducing passive interruptions
Reducing passive interruptions
 
How to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance ToolbeltHow to Add Test Automation to your Quality Assurance Toolbelt
How to Add Test Automation to your Quality Assurance Toolbelt
 
Innovation Academy: Coding 101
Innovation Academy: Coding 101Innovation Academy: Coding 101
Innovation Academy: Coding 101
 
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
 
SEP_Poster
SEP_PosterSEP_Poster
SEP_Poster
 
Kanban for Software Development and Kaizen Culture
Kanban for Software Development and Kaizen CultureKanban for Software Development and Kaizen Culture
Kanban for Software Development and Kaizen Culture
 
All levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-appsAll levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-apps
 
Continous Delivery Toronto Presentation
Continous Delivery Toronto PresentationContinous Delivery Toronto Presentation
Continous Delivery Toronto Presentation
 
How to use apolloJS on React ?
How to use apolloJS on React ?How to use apolloJS on React ?
How to use apolloJS on React ?
 
Shift left-devoxx-pl
Shift left-devoxx-plShift left-devoxx-pl
Shift left-devoxx-pl
 
DevOps/Flow workshop for agile india 2015
DevOps/Flow workshop for agile india 2015DevOps/Flow workshop for agile india 2015
DevOps/Flow workshop for agile india 2015
 

More from Paulo Clavijo

Consumer-Driven Contract Testing - Workshop - January 2021
Consumer-Driven Contract Testing - Workshop - January 2021Consumer-Driven Contract Testing - Workshop - January 2021
Consumer-Driven Contract Testing - Workshop - January 2021Paulo Clavijo
 
Legacy Code and Refactoring Workshop - Session 1 - October 2019
Legacy Code and Refactoring Workshop - Session 1 - October 2019Legacy Code and Refactoring Workshop - Session 1 - October 2019
Legacy Code and Refactoring Workshop - Session 1 - October 2019Paulo Clavijo
 
Outside-in TDD with Test Doubles
Outside-in TDD with Test DoublesOutside-in TDD with Test Doubles
Outside-in TDD with Test DoublesPaulo Clavijo
 
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018Paulo Clavijo
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract TestingPaulo Clavijo
 
ATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónPaulo Clavijo
 
Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4Paulo Clavijo
 
Gestión de Cambios de BBDD con LiquiBase
Gestión de Cambios de BBDD con LiquiBaseGestión de Cambios de BBDD con LiquiBase
Gestión de Cambios de BBDD con LiquiBasePaulo Clavijo
 
Introducción a Spring Roo
Introducción a Spring RooIntroducción a Spring Roo
Introducción a Spring RooPaulo Clavijo
 

More from Paulo Clavijo (9)

Consumer-Driven Contract Testing - Workshop - January 2021
Consumer-Driven Contract Testing - Workshop - January 2021Consumer-Driven Contract Testing - Workshop - January 2021
Consumer-Driven Contract Testing - Workshop - January 2021
 
Legacy Code and Refactoring Workshop - Session 1 - October 2019
Legacy Code and Refactoring Workshop - Session 1 - October 2019Legacy Code and Refactoring Workshop - Session 1 - October 2019
Legacy Code and Refactoring Workshop - Session 1 - October 2019
 
Outside-in TDD with Test Doubles
Outside-in TDD with Test DoublesOutside-in TDD with Test Doubles
Outside-in TDD with Test Doubles
 
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract Testing
 
ATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de AceptaciónATDD - Desarrollo Dirigido por Test de Aceptación
ATDD - Desarrollo Dirigido por Test de Aceptación
 
Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4
 
Gestión de Cambios de BBDD con LiquiBase
Gestión de Cambios de BBDD con LiquiBaseGestión de Cambios de BBDD con LiquiBase
Gestión de Cambios de BBDD con LiquiBase
 
Introducción a Spring Roo
Introducción a Spring RooIntroducción a Spring Roo
Introducción a Spring Roo
 

Recently uploaded

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
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
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
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
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 

Recently uploaded (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
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
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
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
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 

Approval Testing & Mutation Testing - Cork Software Crafters - June 2019

  • 1. Cork Software Crafters Follow us on Twitter: @CorkSwCraft Meetup: www.meetup.com/Cork-Software-Craftsmanship-Meetup Slack: softwarecrafters.slack.com/messages/cork Approval Testing & Mutation Testing 25th June 2019, Cork by Paulo Clavijo (@pclavijo) Thanks
  • 2. Join Software Crafters on Slack. http://slack.softwarecrafters.org #cork
  • 3. We are always looking for new ideas, new talks and mostly new hands-on sessions for our meetups. Contact us if you want to collaborate!
  • 4. 6:15pm - Approval Testing and Mutation Testing introduction. 7:00pm - Hands-on time. 7:45pm - Retrospective Paulo Clavijo (@pclavijo) Agenda Cork Software Crafters
  • 5. Working with Legacy Code Paulo Clavijo @pclavijo Cork Software Crafters
  • 7. Refactoring What? Restructuring code without changing its external behaviour. Why? To make the code easier to change. Paulo Clavijo @pclavijo “Refactoring changes the programs in small steps. If you make a mistake, it is easy to find the bug.” - Martin Fowler “Refactoring is the choreography we use to move code from design A to design B in a safe and efficient way” - Pedro Moreira Santos Cork Software Crafters
  • 8. Characterization Tests Paulo Clavijo @pclavijo Cork Software Crafters
  • 9. “A characterization test (aka Golden Master Testing) is a means to describe the actual behavior of an existing piece of software, and therefore protect existing behavior of legacy code against unintended changes.” - Wikipedia ● Tests to enable refactoring. ● Protects existing behaviour. ● Often used with legacy untested code. ● Quickly results in high coverage. Paulo Clavijo (@pclavijo) Characterization Tests Cork Software Crafters
  • 10. Paulo Clavijo (@pclavijo) Characterization Tests Cork Software Crafters Legacy code can be hard to test, we need to be creative writing our characterization tests and make use of any output available. Think not just in responses from methods or APIs also in other existing side-effects like logging statements, writes to databases, etc.
  • 11. Approval TestS Paulo Clavijo @pclavijo Cork Software Crafters
  • 12. A test technique which compares the current output of your code with an "approved" version. The approved version is created by initially examining the output of your code by hand and approving the result. You can revisit the approved version and easily update it when the requirements change. Paulo Clavijo (@pclavijo) Approval Tests Cork Software Crafters
  • 13. Don’t Tell Me ... Show Me! Paulo Clavijo (@pclavijo)Cork Software Crafters
  • 14. Paulo Clavijo (@pclavijo) Approval Tests Cork Software Crafters public class GreeterTest { @Test public void should_say_hello() { // Arrange Greeter greeter = new Greeter("John Doe"); // Act String greeting = greeter.sayHello(); // Assert assertThat(greeting).isEqualTo("Hello, John Doe!"); } } public class GreeterTest { @Test public void should_say_hello() { // Arrange Greeter greeter = new Greeter("John Doe"); // Act String greeting = greeter.sayHello(); // Verify output against approved Approvals.verify(greeting); } } Assertion-based test Approval test
  • 15. Tracing Coverage Tracing mode enables accurate collection of the branch coverage, with the ability to track tests, view coverage statistic, and get additional information on each covered line.
  • 16. Mutation Testing Paulo Clavijo @pclavijo Cork Software Crafters
  • 17. Coverage is a useful tool to find untested code. Coverage is of little use as a numeric statement of how good your tests are. The problem is that a high coverage can be easily achive with low quality tests. ● 100% coverage with a single test ● 100% coverage with tests without assertions Paulo Clavijo @pclavijo Tests focused on the implementation instead of behaviours and business rules. Cork Software Crafters Coverage != Tests Quality
  • 18. Mutation Testing can be a powerful technique to evaluate the quality of your unit tests. Experiment with small manual mutations in the production code and verify if the tests fail. if (a && b ) { … } if (a || b ) { … } Paulo Clavijo @pclavijo Cork Software Crafters Mutation Testing
  • 19. Automated Mutation Testing tools Paulo Clavijo @pclavijo Cork Software Crafters Mutant for Ruby Infection for PHP MutMut for Python ... for JS, TS, C# and Scalafor Java Mutation Testing
  • 20. Mutation Testing Paulo Clavijo @pclavijo Cork Software Crafters
  • 21. Don’t Tell Me ... Show Me! Paulo Clavijo (@pclavijo)Cork Software Crafters
  • 22. Practice TIME Paulo Clavijo (@pclavijo)Cork Software Crafters
  • 23. Gilded Rose Kata Your task is to add the new feature to our system so that we can begin selling a new category of items. ● "Conjured" items degrade in Quality twice as fast as normal items Feel free to make any changes to the UpdateQuality method and add any new code as long as everything still works correctly. However, do not alter the Item class or Items property. github.com/Cork-Software-Craftsmanship-Community/GildedRose_Refactoring_Kata https://github.com/emilybache/GildedRose-Refactoring-Kata Cork Software Crafters Paulo Clavijo (@pclavijo)
  • 24. Some advice - Find the most idented piece of logic and start refactoring from the right. - Try flattening conditional logic. - A if statement can be removed if we add it to each of is nested statements. - Remove inverted logic on conditional predicates. - Make conditionals similar. Split conditionals (we will duplicate code during some steps). Cork Software Crafters Paulo Clavijo (@pclavijo)
  • 25. Retrospective ● What went well? ● What problems did you encounter? ● What have you learned? ● What surprised you? Paulo Clavijo (@pclavijo)Cork Software Crafters