SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Code Contracts
Code ContractsCode Contracts
Code Contracts
Alexei Skachykhin
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
All Things Open
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
Reginald Stadlbauer
 
Cqrs
CqrsCqrs
Cqrs
Knoldus Inc.
 
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
Ilya Ghirici
 
Contract based testing
Contract based testingContract based testing
Contract based testing
Alisa Petivotova
 
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
sjmarsh
 
Let's Graph
Let's GraphLet's Graph
Let's Graph
Fabien de Maestri
 
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
Haja 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 2018
Paulo 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 Scala
Knoldus 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 Mandziuk
Fwdays
 
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
 
Testing in go
Testing in goTesting in go
Testing in go
Eduardo Felipe Ewert Bonet
 
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 template
AllenKao7
 
AngularJs in Las Palmas de GC
AngularJs in Las Palmas de GCAngularJs in Las Palmas de GC
AngularJs in Las Palmas de GC
Marcin Wosinek
 
Contract testing and Pact
Contract testing and PactContract testing and Pact
Contract testing and Pact
Seb Rose
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
Krazy Koder
 
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
Ilya 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 Testing
sjmarsh
 
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
Haja 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 2018
Paulo 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 Scala
Knoldus 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 Mandziuk
Fwdays
 
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 template
AllenKao7
 
AngularJs in Las Palmas de GC
AngularJs in Las Palmas de GCAngularJs in Las Palmas de GC
AngularJs in Las Palmas de GC
Marcin Wosinek
 
Contract testing and Pact
Contract testing and PactContract testing and Pact
Contract testing and Pact
Seb Rose
 

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
Patroklos Papapetrou (Pat)
 
PYTHON PROGRAMMING TASK.pdf data science pdf
PYTHON PROGRAMMING TASK.pdf data science pdfPYTHON PROGRAMMING TASK.pdf data science pdf
PYTHON PROGRAMMING TASK.pdf data science pdf
akshatraj873
 
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
Jaehoon 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
 
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
Hyperdrive Agile Leadership (powered by Bratton & Company)
 
Test Smarter Not Harder - how to design tests for continuous delivery
Test Smarter Not Harder - how to design tests for continuous deliveryTest Smarter Not Harder - how to design tests for continuous delivery
Test Smarter Not Harder - how to design tests for continuous delivery
Melissa Benua
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
Tsuyoshi 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 Working
Adam Dangoor
 
Hardening
HardeningHardening
Hardening
Diego Pacheco
 
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
Bill Scott
 
Reducing passive interruptions
Reducing passive interruptionsReducing passive interruptions
Reducing passive interruptions
Andrei 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 Toolbelt
Brett Tramposh
 
Innovation Academy: Coding 101
Innovation Academy: Coding 101Innovation Academy: Coding 101
Innovation Academy: Coding 101
Annamarie 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
 
SEP_Poster
SEP_PosterSEP_Poster
SEP_Poster
Bomo Shen
 
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
Acquate
 
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
Andrii Skrypnychenko
 
Continous Delivery Toronto Presentation
Continous Delivery Toronto PresentationContinous Delivery Toronto Presentation
Continous Delivery Toronto Presentation
XebiaLabs
 
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
 
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
Patroklos Papapetrou (Pat)
 
PYTHON PROGRAMMING TASK.pdf data science pdf
PYTHON PROGRAMMING TASK.pdf data science pdfPYTHON PROGRAMMING TASK.pdf data science pdf
PYTHON PROGRAMMING TASK.pdf data science pdf
akshatraj873
 
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
Jaehoon 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
 
Test Smarter Not Harder - how to design tests for continuous delivery
Test Smarter Not Harder - how to design tests for continuous deliveryTest Smarter Not Harder - how to design tests for continuous delivery
Test Smarter Not Harder - how to design tests for continuous delivery
Melissa Benua
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
Tsuyoshi 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 Working
Adam 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 Action
Bill Scott
 
Reducing passive interruptions
Reducing passive interruptionsReducing passive interruptions
Reducing passive interruptions
Andrei 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 Toolbelt
Brett Tramposh
 
Innovation Academy: Coding 101
Innovation Academy: Coding 101Innovation Academy: Coding 101
Innovation Academy: Coding 101
Annamarie 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 Culture
Acquate
 
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
Andrii Skrypnychenko
 
Continous Delivery Toronto Presentation
Continous Delivery Toronto PresentationContinous Delivery Toronto Presentation
Continous Delivery Toronto Presentation
XebiaLabs
 
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
 
Ad

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
Paulo 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 2019
Paulo Clavijo
 
Outside-in TDD with Test Doubles
Outside-in TDD with Test DoublesOutside-in TDD with Test Doubles
Outside-in TDD with Test Doubles
Paulo 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 2018
Paulo Clavijo
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract Testing
Paulo 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ón
Paulo Clavijo
 
Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4
Paulo 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 LiquiBase
Paulo Clavijo
 
Introducción a Spring Roo
Introducción a Spring RooIntroducción a Spring Roo
Introducción a Spring Roo
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 2021
Paulo 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 2019
Paulo Clavijo
 
Outside-in TDD with Test Doubles
Outside-in TDD with Test DoublesOutside-in TDD with Test Doubles
Outside-in TDD with Test Doubles
Paulo 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 2018
Paulo Clavijo
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract Testing
Paulo 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ón
Paulo Clavijo
 
Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4Tests Unitarios con JUnit 4
Tests Unitarios con JUnit 4
Paulo 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 LiquiBase
Paulo Clavijo
 
Introducción a Spring Roo
Introducción a Spring RooIntroducción a Spring Roo
Introducción a Spring Roo
Paulo Clavijo
 
Ad

Recently uploaded (20)

2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 

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