際際滷

際際滷Share a Scribd company logo
An Overview of the
automated testing
And the forgotten level of the
testing pyramid
Why is a
programmer
talking about
tests?
Pros vs Cons
Why?
Is it worth
it ?
Whyshould anyone write automated tests?
One should write an automated test 
  to achieve a good design.
  to clarify how the system works.
  to understand the system.
  to minimize risks.
  to test a system.
Is it worth it? Automatize tests require
  time to write.
  time to adjust, fix and maintain.
  time to setup/execute.
How to minimize the efforts?
Writing tests that...
 ... are easy to run.
  are easy to write.
  require minimal maintenance.
Case scenario
MD5?
OCR?
Don't overestimate assertion over
output!!!
Name: Hannah
Date: 14th September
Feature: Loves her cat
Pebbles
How to test?
Gathering information
"Truth can only be found in one place: the code."
 Robert C. Martin, Clean Code
Unit Test
 What the
developer
wants
Acceptance
Test
 What the
customer
wants
Code
 What the
program
does
Different perspectives
What developers want
 There are two main issues that concern the
programmer:
 The complexity
 The risk
Dealing with complexity
There is only one way to deal with complexity: avoiding it, usually by
abstraction
 Separation of concerns
 High level of abstraction
Wishful thinking: imagine there is a
function that solves the problem
TDD and Abstraction
 Describe our intentions before we write how (single responsibility)
 Minimize the number of collaborators.
 Minimize the scope.
Additional goodies
Unit Tests Limitations
- if the units work well in isolation, we do not know if they work well
together.
- Unit tests rely on doubles
(specially mocks and stubs).
There is a sane level of usage
for mocks!!!
What the customer wants
 What the customer wants  Acceptance test
 Acceptance test  definition of done + system documentation
 Practical scenarios helps to identify ambiguous and contradictory
requirements.
 Acceptance tests focus on real user scenarios
Acceptance tests limitations
 They are slow
 They are fragile and sometimes not reliable.
 They are not isolated
 They are not very practical
Lost layer of Test pyramid
Presentation Layer Test
Service Layer Test
Subcutaneous Test
Persistence Layer Test
Layered testing
BONUS
Mocks overuse / pedantic unit test
@Test
public void testCreditCardIsCharged() {
paymentProcessor = new PaymentProcessor(mockCreditCardServer);
when(mockCreditCardServer.isServerAvailable()).thenReturn(true);
when(mockCreditCardServer.beginTransaction())
.thenReturn(mockTransactionManager);
when(mockTransactionManager.getTransaction())
.thenReturn(transaction);
when(mockCreditCardServer.pay(transaction, creditCard, 500))
.thenReturn(mockPayment);
when(mockPayment.isOverMaxBalance()).thenReturn(false);
paymentProcessor
.processPayment(creditCard, Money.ofMajor(CurrencyUnit.USD, 500));
verify(mockCreditCardServer).pay(transaction, creditCard, 500);
}
Questions?
Rodrigo di Lorenzo Lopes
rdllopes@gmail.com

More Related Content

What's hot (19)

The problem with tdd
The problem with tddThe problem with tdd
The problem with tdd
Dror Helper
TDD - Designing with Expectations, not Implementations
TDD - Designing with Expectations, not ImplementationsTDD - Designing with Expectations, not Implementations
TDD - Designing with Expectations, not Implementations
Harshith Shetty
User Story vs. UseCase : Introductory Primer
User Story vs. UseCase : Introductory PrimerUser Story vs. UseCase : Introductory Primer
User Story vs. UseCase : Introductory Primer
Kristyn Greenwood
Unit testing
Unit testingUnit testing
Unit testing
PiXeL16
Code Review
Code ReviewCode Review
Code Review
Mikalai Alimenkou
Exploratory testing
Exploratory testingExploratory testing
Exploratory testing
Harshani Wickramaarachchi
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
Mihail Gaberov
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
Steven Mak
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Samnang Chhun
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
Foyzul Karim
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Md. Hasan Basri (Angel)
Value of Unit Testing
Value of Unit TestingValue of Unit Testing
Value of Unit Testing
Ferose Khan J
Clean Code
Clean CodeClean Code
Clean Code
swaraj Patil
Unit testing
Unit testingUnit testing
Unit testing
Adam Birr
Clean code
Clean codeClean code
Clean code
Uday Pratap Singh
Delhi second draft
Delhi second draft Delhi second draft
Delhi second draft
vaibhav lokhande
Keeping business logic out of your UIs
Keeping business logic out of your UIsKeeping business logic out of your UIs
Keeping business logic out of your UIs
Petter Holmstr旦m
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
Eyal Kenig
Unit testing in PHP
Unit testing in PHPUnit testing in PHP
Unit testing in PHP
Chonlasith Jucksriporn
The problem with tdd
The problem with tddThe problem with tdd
The problem with tdd
Dror Helper
TDD - Designing with Expectations, not Implementations
TDD - Designing with Expectations, not ImplementationsTDD - Designing with Expectations, not Implementations
TDD - Designing with Expectations, not Implementations
Harshith Shetty
User Story vs. UseCase : Introductory Primer
User Story vs. UseCase : Introductory PrimerUser Story vs. UseCase : Introductory Primer
User Story vs. UseCase : Introductory Primer
Kristyn Greenwood
Unit testing
Unit testingUnit testing
Unit testing
PiXeL16
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
Mihail Gaberov
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
Steven Mak
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Samnang Chhun
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
Foyzul Karim
Value of Unit Testing
Value of Unit TestingValue of Unit Testing
Value of Unit Testing
Ferose Khan J
Unit testing
Unit testingUnit testing
Unit testing
Adam Birr
Keeping business logic out of your UIs
Keeping business logic out of your UIsKeeping business logic out of your UIs
Keeping business logic out of your UIs
Petter Holmstr旦m
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
Eyal Kenig

Similar to An Overview of automated testing (1) (20)

Lessons Learned When Automating
Lessons Learned When AutomatingLessons Learned When Automating
Lessons Learned When Automating
Alan Richardson
Why Automated Testing Matters To DevOps
Why Automated Testing Matters To DevOpsWhy Automated Testing Matters To DevOps
Why Automated Testing Matters To DevOps
dpaulmerrill
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
Nacho Cougil
Before Kaggle : from a business goal to a Machine Learning problem
Before Kaggle : from a business goal to a Machine Learning problem Before Kaggle : from a business goal to a Machine Learning problem
Before Kaggle : from a business goal to a Machine Learning problem
Dataiku
Before Kaggle
Before KaggleBefore Kaggle
Before Kaggle
Pierre Gutierrez
QA and scrum
QA and scrumQA and scrum
QA and scrum
clintonbosch
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
Nacho Cougil
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
ssusercaf6c1
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Nacho Cougil
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
MaslowB
An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final Review
Blue Elephant Consulting
TDD: seriously, try it!
TDD: seriously, try it! TDD: seriously, try it!
TDD: seriously, try it!
Nacho Cougil
Devday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvuDevday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvu
Phat VU
Exploratory Testing Explained
Exploratory Testing ExplainedExploratory Testing Explained
Exploratory Testing Explained
TechWell
Tec314f
Tec314fTec314f
Tec314f
John Art
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
Ganesh Kondal
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
IIITA
User Stories from Scenarios
User Stories from ScenariosUser Stories from Scenarios
User Stories from Scenarios
Ravikanth-BA
Automated testers agile evangelist
Automated testers agile evangelistAutomated testers agile evangelist
Automated testers agile evangelist
Arrows Group
Lessons Learned When Automating
Lessons Learned When AutomatingLessons Learned When Automating
Lessons Learned When Automating
Alan Richardson
Why Automated Testing Matters To DevOps
Why Automated Testing Matters To DevOpsWhy Automated Testing Matters To DevOps
Why Automated Testing Matters To DevOps
dpaulmerrill
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
Nacho Cougil
Before Kaggle : from a business goal to a Machine Learning problem
Before Kaggle : from a business goal to a Machine Learning problem Before Kaggle : from a business goal to a Machine Learning problem
Before Kaggle : from a business goal to a Machine Learning problem
Dataiku
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
Nacho Cougil
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Tr坦jmiasto Java User Group (17th May '23)
ssusercaf6c1
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
Nacho Cougil
Introduzione allo Unit Testing
Introduzione allo Unit TestingIntroduzione allo Unit Testing
Introduzione allo Unit Testing
Stefano Ottaviani
Type mock isolator
Type mock isolatorType mock isolator
Type mock isolator
MaslowB
An Introduction To Software Development - Final Review
An Introduction To Software Development - Final ReviewAn Introduction To Software Development - Final Review
An Introduction To Software Development - Final Review
Blue Elephant Consulting
TDD: seriously, try it!
TDD: seriously, try it! TDD: seriously, try it!
TDD: seriously, try it!
Nacho Cougil
Devday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvuDevday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvu
Phat VU
Exploratory Testing Explained
Exploratory Testing ExplainedExploratory Testing Explained
Exploratory Testing Explained
TechWell
Tec314f
Tec314fTec314f
Tec314f
John Art
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
Ganesh Kondal
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
IIITA
User Stories from Scenarios
User Stories from ScenariosUser Stories from Scenarios
User Stories from Scenarios
Ravikanth-BA
Automated testers agile evangelist
Automated testers agile evangelistAutomated testers agile evangelist
Automated testers agile evangelist
Arrows Group

An Overview of automated testing (1)

  • 1. An Overview of the automated testing And the forgotten level of the testing pyramid
  • 3. Pros vs Cons Why? Is it worth it ?
  • 4. Whyshould anyone write automated tests? One should write an automated test to achieve a good design. to clarify how the system works. to understand the system. to minimize risks. to test a system.
  • 5. Is it worth it? Automatize tests require time to write. time to adjust, fix and maintain. time to setup/execute.
  • 6. How to minimize the efforts? Writing tests that... ... are easy to run. are easy to write. require minimal maintenance.
  • 7. Case scenario MD5? OCR? Don't overestimate assertion over output!!! Name: Hannah Date: 14th September Feature: Loves her cat Pebbles How to test?
  • 8. Gathering information "Truth can only be found in one place: the code." Robert C. Martin, Clean Code Unit Test What the developer wants Acceptance Test What the customer wants Code What the program does
  • 10. What developers want There are two main issues that concern the programmer: The complexity The risk
  • 11. Dealing with complexity There is only one way to deal with complexity: avoiding it, usually by abstraction Separation of concerns High level of abstraction Wishful thinking: imagine there is a function that solves the problem
  • 12. TDD and Abstraction Describe our intentions before we write how (single responsibility) Minimize the number of collaborators. Minimize the scope.
  • 14. Unit Tests Limitations - if the units work well in isolation, we do not know if they work well together. - Unit tests rely on doubles (specially mocks and stubs). There is a sane level of usage for mocks!!!
  • 15. What the customer wants What the customer wants Acceptance test Acceptance test definition of done + system documentation Practical scenarios helps to identify ambiguous and contradictory requirements. Acceptance tests focus on real user scenarios
  • 16. Acceptance tests limitations They are slow They are fragile and sometimes not reliable. They are not isolated They are not very practical
  • 17. Lost layer of Test pyramid Presentation Layer Test Service Layer Test Subcutaneous Test Persistence Layer Test
  • 19. BONUS
  • 20. Mocks overuse / pedantic unit test @Test public void testCreditCardIsCharged() { paymentProcessor = new PaymentProcessor(mockCreditCardServer); when(mockCreditCardServer.isServerAvailable()).thenReturn(true); when(mockCreditCardServer.beginTransaction()) .thenReturn(mockTransactionManager); when(mockTransactionManager.getTransaction()) .thenReturn(transaction); when(mockCreditCardServer.pay(transaction, creditCard, 500)) .thenReturn(mockPayment); when(mockPayment.isOverMaxBalance()).thenReturn(false); paymentProcessor .processPayment(creditCard, Money.ofMajor(CurrencyUnit.USD, 500)); verify(mockCreditCardServer).pay(transaction, creditCard, 500); }
  • 21. Questions? Rodrigo di Lorenzo Lopes rdllopes@gmail.com