SlideShare a Scribd company logo
1 of 23
Software Testing
Fundamentals
What do you expect from your dream
product(car) ?
Answers from audience
Milage
Features
mentioned in
broacher
Comfort
Should ride.
Should have high
ground clearance
Who is responsible for making sure the features
and functionalities are as mentioned
Showroom owner
Showroom executive
Manufacturing plant owner
Specific car manufacturing unit manager
Quality Assurance team - Responsible for certifying the functionalities
Why Testing is important ?
To deliver reliable
product
Product delivers what is
promised
It does not malfunction
To deliver a quality
product
Product should be
durable
Product should tolerate
few error conditions
Types of software testing
Manual Automation
Test the features of
Rectangle
Rectangle Class
public class Rectangle {
public double getArea(double length, double width){
validateForZeroLength(length, width);
return length * width;
}
private void validateForZeroLength(double length, double width) {
if (length <= 0.0 || width <= 0.0) {
throw new RuntimeException("Invalid values are received for either length or width");
}
}
}
public class ManualTestScenarios {
public static void main(String[] args) {
// test the area
// scenarios
// pass different values (10,20) , (100,200.5) , (1,2)
// test for zero length
Rectangle rectangle = new Rectangle();
double area = rectangle.getArea(300.5, 200.9);
System.out.println("Area of rectangle having length:"+300.5+" and "+200.9+" width is "+area);
area = rectangle.getArea(1, 1);
System.out.println("Area of rectangle having length:"+1+" and "+1+" width is "+area);
try {
area = rectangle.getArea(0, 0);
}catch(RuntimeException runtimeException ){
System.out.println(runtimeException.getMessage());
}
}
}
Disadvantage of manual tests
Time consuming
and Expensive
Routine and Boring
Must be repeated
by all Stakeholders
Automation tests for Rectangle class
class RectangleTest {
@Test
void getAreaForWholeNumberLengths() {
Rectangle rectangle = new Rectangle();
double area = rectangle.getArea(10, 20);
assertEquals(200.0, area);
area = rectangle.getArea(1, 2);
assertEquals(2, area);
}
@Test
void getAreaForDecimalNumberLengths() {
Rectangle rectangle = new Rectangle();
double area = rectangle.getArea(10.5, 20.9);
assertEquals(219.45, area);
area = rectangle.getArea(100.3, 2456.7);
assertEquals(246407.01, area, 0.001);
}
@Test
void getAreaForZeroWidthRectangle() {
Rectangle rectangle = new Rectangle();
assertThrows(RuntimeException.class, ()-> rectangle.getArea(10.5, 0.0));
}
}
Why Automation tests are important ?
Builds a safety net and
defend against other
programmers
Reusable and
Repeatable
Reduce Bugs in New
features as well as in
existing features
Allow refactoring with
confidence
Improve Design
Documents the
features
Reduce the need of the
IDE debugger
Types of
automation
tests
Unit test
Component test
Integration test
End-to-End test
GUI test
Performance test, Stress/Load test
Acceptance test
Test Pyramid that looked like
Manual tests,
Exploratory tests
Inverting the test pyramid
1 - 5 % manual tests
Criteria for
good Unit
tests
Small and Simple:
• Easy to quickly comprehend
Runs Fast
Express intent and not the implementation details
Runs independently and in isolation
Runs in Parallel
Repeatable
Understand
Java Project
setup
 SRC
 Main
 Java
 Resources
 Test
 Java
Write few unit
tests for
Calculator
functionalities
 Structure of a typical test
 Given
 preconditions
 When
 Calling a function
 Then
 Verify the result
 Test Result
 Success
 Failed
 Error
Libraries for writing unit tests
 JUNIT
 Junit 4.x
 Junit 5.x
 SPOCK
 CUCUMBER
 MOCKITO
 POWERMOCK
Test Driven Development
Test, Code, Refactor
TDD
Methodology to write tests first
Focus on minimalistic code design
Speculative generality is avoided
Evolutionary design
 Write a test for the next bit of
functionality you want to add.
 Write the functional code until the
test passes.
 Refactor both new and old code to
make it well structured.
 Test- Code – Test- Refactor-Test
Add a test
Does it pass ?
Add enough
code to pass
the test
Refactor/Add
features
No
Run the tests
Yes
TDD Demo
Thank you
References
 https://www.martinfowler.com/bliki/TestDrivenDevelopment.h
tml
 https://www.slideshare.net/nashjain/tdd-overview

More Related Content

Similar to Software Testing Fundamentals: Automation Tests Invert the Test Pyramid

Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsBhavin Javia
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Atagg2015 - Agile Testing by Leveraging Cloud
Atagg2015 - Agile Testing by Leveraging CloudAtagg2015 - Agile Testing by Leveraging Cloud
Atagg2015 - Agile Testing by Leveraging CloudAgile Testing Alliance
 
Testing Interview Questions.pdf
Testing Interview Questions.pdfTesting Interview Questions.pdf
Testing Interview Questions.pdfPradeepaKannan6
 
"Experiences Of Test Automation At Spotify" with Kristian Karl
"Experiences Of Test Automation At Spotify" with Kristian Karl"Experiences Of Test Automation At Spotify" with Kristian Karl
"Experiences Of Test Automation At Spotify" with Kristian KarlTEST Huddle
 
Getting Started With QA Automation
Getting Started With QA AutomationGetting Started With QA Automation
Getting Started With QA AutomationGiovanni Scerra ☃
 
Overview of Lab Management and TFS
Overview of Lab Management and TFSOverview of Lab Management and TFS
Overview of Lab Management and TFSChris Kadel, MBA
 
Atagg 2015 Test automation and effective continuous integration
Atagg 2015 Test automation and effective continuous integrationAtagg 2015 Test automation and effective continuous integration
Atagg 2015 Test automation and effective continuous integrationAgile Testing Alliance
 
Visual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewVisual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewSteve Lange
 
The quality assurance checklist for progressive testing
The quality assurance checklist for progressive testingThe quality assurance checklist for progressive testing
The quality assurance checklist for progressive testingMaitrikpaida
 
The Quality Assurance Checklist for Progressive Testing
The Quality Assurance Checklist for Progressive TestingThe Quality Assurance Checklist for Progressive Testing
The Quality Assurance Checklist for Progressive TestingCygnet Infotech
 
Qspectrum - Cloud based Test Automation Solutions
Qspectrum - Cloud based Test Automation SolutionsQspectrum - Cloud based Test Automation Solutions
Qspectrum - Cloud based Test Automation SolutionsQSpectrum
 
Automate test, tools, advantages, and disadvantages
Automate test, tools, advantages,  and disadvantagesAutomate test, tools, advantages,  and disadvantages
Automate test, tools, advantages, and disadvantagesMajid Hosseini
 
Neotys PAC 2018 - Ramya Ramalinga Moorthy
Neotys PAC 2018 - Ramya Ramalinga MoorthyNeotys PAC 2018 - Ramya Ramalinga Moorthy
Neotys PAC 2018 - Ramya Ramalinga MoorthyNeotys_Partner
 
How Not To Be Caught Flat-footed With Unpredictable FME Results
How Not To Be Caught Flat-footed With Unpredictable FME ResultsHow Not To Be Caught Flat-footed With Unpredictable FME Results
How Not To Be Caught Flat-footed With Unpredictable FME ResultsSafe Software
 

Similar to Software Testing Fundamentals: Automation Tests Invert the Test Pyramid (20)

Performance Testing - Keytorc Approach
Performance Testing - Keytorc ApproachPerformance Testing - Keytorc Approach
Performance Testing - Keytorc Approach
 
Unit testing
Unit testingUnit testing
Unit testing
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Atagg2015 - Agile Testing by Leveraging Cloud
Atagg2015 - Agile Testing by Leveraging CloudAtagg2015 - Agile Testing by Leveraging Cloud
Atagg2015 - Agile Testing by Leveraging Cloud
 
Testing Interview Questions.pdf
Testing Interview Questions.pdfTesting Interview Questions.pdf
Testing Interview Questions.pdf
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
"Experiences Of Test Automation At Spotify" with Kristian Karl
"Experiences Of Test Automation At Spotify" with Kristian Karl"Experiences Of Test Automation At Spotify" with Kristian Karl
"Experiences Of Test Automation At Spotify" with Kristian Karl
 
Getting Started With QA Automation
Getting Started With QA AutomationGetting Started With QA Automation
Getting Started With QA Automation
 
Overview of Lab Management and TFS
Overview of Lab Management and TFSOverview of Lab Management and TFS
Overview of Lab Management and TFS
 
Atagg 2015 Test automation and effective continuous integration
Atagg 2015 Test automation and effective continuous integrationAtagg 2015 Test automation and effective continuous integration
Atagg 2015 Test automation and effective continuous integration
 
Visual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewVisual Studio 2010 Testing Overview
Visual Studio 2010 Testing Overview
 
UI Testing
UI TestingUI Testing
UI Testing
 
The quality assurance checklist for progressive testing
The quality assurance checklist for progressive testingThe quality assurance checklist for progressive testing
The quality assurance checklist for progressive testing
 
The Quality Assurance Checklist for Progressive Testing
The Quality Assurance Checklist for Progressive TestingThe Quality Assurance Checklist for Progressive Testing
The Quality Assurance Checklist for Progressive Testing
 
Qspectrum - Cloud based Test Automation Solutions
Qspectrum - Cloud based Test Automation SolutionsQspectrum - Cloud based Test Automation Solutions
Qspectrum - Cloud based Test Automation Solutions
 
Automate test, tools, advantages, and disadvantages
Automate test, tools, advantages,  and disadvantagesAutomate test, tools, advantages,  and disadvantages
Automate test, tools, advantages, and disadvantages
 
Neotys PAC 2018 - Ramya Ramalinga Moorthy
Neotys PAC 2018 - Ramya Ramalinga MoorthyNeotys PAC 2018 - Ramya Ramalinga Moorthy
Neotys PAC 2018 - Ramya Ramalinga Moorthy
 
How Not To Be Caught Flat-footed With Unpredictable FME Results
How Not To Be Caught Flat-footed With Unpredictable FME ResultsHow Not To Be Caught Flat-footed With Unpredictable FME Results
How Not To Be Caught Flat-footed With Unpredictable FME Results
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 

Software Testing Fundamentals: Automation Tests Invert the Test Pyramid

  • 2. What do you expect from your dream product(car) ?
  • 3. Answers from audience Milage Features mentioned in broacher Comfort Should ride. Should have high ground clearance
  • 4. Who is responsible for making sure the features and functionalities are as mentioned Showroom owner Showroom executive Manufacturing plant owner Specific car manufacturing unit manager Quality Assurance team - Responsible for certifying the functionalities
  • 5. Why Testing is important ? To deliver reliable product Product delivers what is promised It does not malfunction To deliver a quality product Product should be durable Product should tolerate few error conditions
  • 6. Types of software testing Manual Automation
  • 7. Test the features of Rectangle
  • 8. Rectangle Class public class Rectangle { public double getArea(double length, double width){ validateForZeroLength(length, width); return length * width; } private void validateForZeroLength(double length, double width) { if (length <= 0.0 || width <= 0.0) { throw new RuntimeException("Invalid values are received for either length or width"); } } } public class ManualTestScenarios { public static void main(String[] args) { // test the area // scenarios // pass different values (10,20) , (100,200.5) , (1,2) // test for zero length Rectangle rectangle = new Rectangle(); double area = rectangle.getArea(300.5, 200.9); System.out.println("Area of rectangle having length:"+300.5+" and "+200.9+" width is "+area); area = rectangle.getArea(1, 1); System.out.println("Area of rectangle having length:"+1+" and "+1+" width is "+area); try { area = rectangle.getArea(0, 0); }catch(RuntimeException runtimeException ){ System.out.println(runtimeException.getMessage()); } } }
  • 9. Disadvantage of manual tests Time consuming and Expensive Routine and Boring Must be repeated by all Stakeholders
  • 10. Automation tests for Rectangle class class RectangleTest { @Test void getAreaForWholeNumberLengths() { Rectangle rectangle = new Rectangle(); double area = rectangle.getArea(10, 20); assertEquals(200.0, area); area = rectangle.getArea(1, 2); assertEquals(2, area); } @Test void getAreaForDecimalNumberLengths() { Rectangle rectangle = new Rectangle(); double area = rectangle.getArea(10.5, 20.9); assertEquals(219.45, area); area = rectangle.getArea(100.3, 2456.7); assertEquals(246407.01, area, 0.001); } @Test void getAreaForZeroWidthRectangle() { Rectangle rectangle = new Rectangle(); assertThrows(RuntimeException.class, ()-> rectangle.getArea(10.5, 0.0)); } }
  • 11. Why Automation tests are important ? Builds a safety net and defend against other programmers Reusable and Repeatable Reduce Bugs in New features as well as in existing features Allow refactoring with confidence Improve Design Documents the features Reduce the need of the IDE debugger
  • 12. Types of automation tests Unit test Component test Integration test End-to-End test GUI test Performance test, Stress/Load test Acceptance test
  • 13. Test Pyramid that looked like Manual tests, Exploratory tests
  • 14. Inverting the test pyramid 1 - 5 % manual tests
  • 15. Criteria for good Unit tests Small and Simple: • Easy to quickly comprehend Runs Fast Express intent and not the implementation details Runs independently and in isolation Runs in Parallel Repeatable
  • 16. Understand Java Project setup  SRC  Main  Java  Resources  Test  Java
  • 17. Write few unit tests for Calculator functionalities  Structure of a typical test  Given  preconditions  When  Calling a function  Then  Verify the result  Test Result  Success  Failed  Error
  • 18. Libraries for writing unit tests  JUNIT  Junit 4.x  Junit 5.x  SPOCK  CUCUMBER  MOCKITO  POWERMOCK
  • 19. Test Driven Development Test, Code, Refactor TDD Methodology to write tests first Focus on minimalistic code design Speculative generality is avoided Evolutionary design
  • 20.  Write a test for the next bit of functionality you want to add.  Write the functional code until the test passes.  Refactor both new and old code to make it well structured.  Test- Code – Test- Refactor-Test Add a test Does it pass ? Add enough code to pass the test Refactor/Add features No Run the tests Yes