SlideShare 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)

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

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

PDF
Unit testing - An introduction
Alejandro Claro Mosqueda
 
PPTX
Testing 101
Noam Barkai
 
PPTX
Beginners overview of automated testing with Rspec
jeffrey1ross
 
PPTX
.NET Fest 2019. Arnon Axelrod. Test automation for developers
NETFest
 
PPT
Automated testing overview
Alex Pop
 
PDF
The Evolution of Development Testing
Cathal King
 
PDF
Unit Testing
Scott Leberknight
 
PPTX
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
michael.labriola
 
PDF
Writing Tests Effectively
Paul Boocock
 
PDF
Testing and TDD - KoJUG
lburdz
 
PPTX
TDD Best Practices
Attila Bertók
 
PDF
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
AgileNetwork
 
PPTX
Software testing
Nico Heidtke
 
PDF
Test driven development
Dennis Ahaus
 
PPTX
Testing
Christian Rubiales
 
PPT
Automated Testing vs Manual Testing.ppt
ZakriyaMalik2
 
PPT
Automated Testing v s Manual Testing.ppt
ZakriyaMalik2
 
PDF
Automated testing-whitepaper
imdurgesh
 
PPT
An insight to test driven development and unit testing
Dharmendra Prasad
 
PDF
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Unit testing - An introduction
Alejandro Claro Mosqueda
 
Testing 101
Noam Barkai
 
Beginners overview of automated testing with Rspec
jeffrey1ross
 
.NET Fest 2019. Arnon Axelrod. Test automation for developers
NETFest
 
Automated testing overview
Alex Pop
 
The Evolution of Development Testing
Cathal King
 
Unit Testing
Scott Leberknight
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
michael.labriola
 
Writing Tests Effectively
Paul Boocock
 
Testing and TDD - KoJUG
lburdz
 
TDD Best Practices
Attila Bertók
 
Agile Mumbai 2020 Conference | How to get the best ROI on Your Test Automati...
AgileNetwork
 
Software testing
Nico Heidtke
 
Test driven development
Dennis Ahaus
 
Automated Testing vs Manual Testing.ppt
ZakriyaMalik2
 
Automated Testing v s Manual Testing.ppt
ZakriyaMalik2
 
Automated testing-whitepaper
imdurgesh
 
An insight to test driven development and unit testing
Dharmendra Prasad
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Ad

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); }