SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler offline
UNIT & 
INTEGRATION 
TESTING 
David Berliner
Why Test 
Types of Tests 
PHPUnit 
Writing Tests 
Getting Stuck In
WHY TEST?
TESTS REDUCE BUGS
TESTS REDUCE BUGS 
TESTS ARE GOOD DOCUMENTATION
TESTS REDUCE BUGS 
TESTS ARE GOOD DOCUMENTATION 
TESTS ALLOW SAFE REFACTORING
TESTS REDUCE BUGS 
TESTS ARE GOOD DOCUMENTATION 
TESTS ALLOW SAFE REFACTORING 
TESTS REDUCE THE COST OF CHANGE
TESTS REDUCE BUGS 
TESTS ARE GOOD DOCUMENTATION 
TESTS ALLOW SAFE REFACTORING 
TESTS REDUCE THE COST OF CHANGE 
TESTING FORCES YOU TO THINK
TESTS REDUCE BUGS 
TESTS ARE GOOD DOCUMENTATION 
TESTS ALLOW SAFE REFACTORING 
TESTS REDUCE THE COST OF CHANGE 
TESTING FORCES YOU TO THINK 
TESTS REDUCE FEAR
A study conducted by Microsoft and 
IBM showed that writing tests can 
add 15% – 35% to development time 
but reduce the number of bugs by 
40% – 90%. 
http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf
TYPES OF TESTS
Black Box 
White Box 
Unit 
Integration 
Functional 
System 
Regression 
Performance 
Smoke 
Canary 
Usability 
A/B 
…
Black Box 
White Box 
Unit 
Integration 
Functional 
System 
Regression 
Performance 
Smoke 
Canary 
Usability 
A/B 
…
UNIT TESTS 
The goal of unit testing is: 
1. to isolate each part of the program, and
UNIT TESTS 
The goal of unit testing is: 
1. to isolate each part of the program, and 
2. show that the individual parts are correct.
UNIT TESTS 
The goal of unit testing is: 
1. to isolate each part of the program, and 
2. show that the individual parts are correct. 
Unit tests have a very narrow and well-defined scope.
UNIT TESTS 
Pro’s: 
1. Fast
UNIT TESTS 
Pro’s: 
1. Fast 
2. Simple to understand
UNIT TESTS 
Pro’s: 
1. Fast 
2. Simple to understand 
3. Reliable
UNIT TESTS 
Pro’s: 
1. Fast 
2. Simple to understand 
3. Reliable 
Con’s: 
1. Large time investment
UNIT TESTS 
Pro’s: 
1. Fast 
2. Simple to understand 
3. Reliable 
Con’s: 
1. Large time investment 
2. Requires maintenance
UNIT TESTS 
A unit test should NOT: 
1. Access the network
UNIT TESTS 
A unit test should NOT: 
1. Access the network 
2. Hit a database
UNIT TESTS 
A unit test should NOT: 
1. Access the network 
2. Hit a database 
3. Use the file system
UNIT TESTS 
A unit test should NOT: 
1. Access the network 
2. Hit a database 
3. Use the file system 
4. Call other non-trivial components
INTEGRATION TESTS 
Test the inter-operation of multiple subsystems. 
Pro’s: 
1. Make sure nuts and bolts 
fit together
INTEGRATION TESTS 
Test the inter-operation of multiple subsystems. 
Pro’s: 
1. Make sure nuts and bolts 
fit together 
2. Test behaviour 
and infrastructure
INTEGRATION TESTS 
Test the inter-operation of multiple subsystems. 
Pro’s: 
1. Make sure nuts and bolts 
fit together 
2. Test behaviour 
and infrastructure 
3. (tested code) / test % is high
INTEGRATION TESTS 
Test the inter-operation of multiple subsystems. 
Pro’s: 
1. Make sure nuts and bolts 
fit together 
2. Test behaviour 
and infrastructure 
3. (tested code) / test % is high 
Con’s: 
1. Hard to test all critical paths
INTEGRATION TESTS 
Test the inter-operation of multiple subsystems. 
Pro’s: 
1. Make sure nuts and bolts 
fit together 
2. Test behaviour 
and infrastructure 
3. (tested code) / test % is high 
Con’s: 
1. Hard to test all critical paths 
2. Harder to localise source 
of errors
TEST HIERARCHY
PHPUnit
1. Unit Testing Framework written in PHP by Sebastian Bergmann 
2. De facto standard 
3. Major Frameworks use it (Zend, Cake, Laravel, Symphony etc.)
Installation: 
https://phpunit.de/manual/current/en/installation.html 
Be sure to install xDebug in order to generate code coverage. 
Note: PECL no longer supported
WRITING TESTS
ORGANISING TESTS 
- The tests for class Foo are placed in a class FooTest 
- Most of the time you will inherit from 
PHPUnit_Framework_TestCase 
PHPUnit_Extensions_Database_TestCase 
- Tests are public methods named test* 
- Inside the test methods, assertion methods such as 
assertEquals() are used.
ORGANISING TESTS 
Tests should mirror the code being tested. 
SRC 
SomeFolder 
Baz.php 
Foo.php 
Bar.php 
TEST 
SomeFolder 
FooTest.php 
BarTest.php 
BazTest.php
PHPUNIT.XML
BOOTSTRAP.PHP
ASSERTIONS 
assertArrayHasKey() 
assertClassHasAttribute() 
assertClassHasStaticAttribute() 
assertContains() 
assertContainsOnly() 
assertContainsOnlyInstancesOf() 
assertCount() 
assertEmpty() 
assertEqualXMLStructure() 
assertEquals() 
assertFalse() 
assertFileEquals() 
assertFileExists() 
assertGreaterThan() 
assertGreaterThanOrEqual() 
assertInstanceOf() 
assertInternalType() 
assertJsonFileEqualsJsonFile() 
assertJsonStringEqualsJsonFile() 
assertJsonStringEqualsJsonString() 
assertLessThan() 
assertLessThanOrEqual() 
assertNull ( ) 
assertObjectHasAttribute() 
assertRegExp() 
assertStringMatchesFormat() 
assertStringMatchesFormatFile() 
assertSame() 
assertStringEndsWi th() 
assertStringEqualsFile() 
assertStringStartsWi th() 
assertThat() 
assertTrue() 
assertXmlFileEqualsXmlFile() 
assertXmlStringEqualsXmlFile() 
assertXmlStringEqualsXmlString()
ASSERTIONS
ANNOTATIONS @DEPENDS
ANNOTATIONS @DATAPROVIDER
ANNOTATIONS @EXCEPTIONS
What do you do if the code you want to test 
is dependent on other components that 
cannot be used in the test environment?
MOCKS & STUBS
DATABASE TESTING 
Four stages of a DB test 
1. Set up fixture 
2. Exercise System Under Test 
3. Verify outcome 
4. Teardown
DATABASE TESTING (CONT) Give it a connection
DATABASE TESTING (CONT) Flat XML DataSet
DATABASE TESTING (CONT)
DATABASE TESTING (CONT)
GETTING STUCK IN
Demo: 
https://github.com/manatok/talk-demo-ci
• db - Database Skel file and patches 
• src - Project Code 
• test/Output - Code coverage 
• test/SportsBet - Projects Tests 
• test/TestingCore - Uti l i ties 
• tools - CI tools including ANT build 
file
Unit and integration Testing

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Unit Testing vs Integration Testing
Unit Testing vs Integration TestingUnit Testing vs Integration Testing
Unit Testing vs Integration Testing
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Unit Testing (C#)
Unit Testing (C#)Unit Testing (C#)
Unit Testing (C#)
 
Unit testing
Unit testingUnit testing
Unit testing
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
 
Selenium webdriver interview questions and answers
Selenium webdriver interview questions and answersSelenium webdriver interview questions and answers
Selenium webdriver interview questions and answers
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Introduction & Manual Testing
Introduction & Manual TestingIntroduction & Manual Testing
Introduction & Manual Testing
 
Test automation
Test automationTest automation
Test automation
 
Manual testing
Manual testingManual testing
Manual testing
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Sanity testing and smoke testing
Sanity testing and smoke testingSanity testing and smoke testing
Sanity testing and smoke testing
 

Semelhante a Unit and integration Testing

Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
TEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGTEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGsuhasreddy1
 
Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Mohamed Taman
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 
ISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture NotesISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture Notesonsoftwaretest
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1Yogindernath Gupta
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Qualityguest268ee8
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTscatherinewall
 
Testing on frontend
Testing on frontendTesting on frontend
Testing on frontendAfif Alfiano
 
An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testingAdam Stephensen
 

Semelhante a Unit and integration Testing (20)

Application Testing
Application TestingApplication Testing
Application Testing
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Unit testing
Unit testingUnit testing
Unit testing
 
Test execution may_04_2006
Test execution may_04_2006Test execution may_04_2006
Test execution may_04_2006
 
TEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTINGTEST EXECUTION AND REPORTING
TEST EXECUTION AND REPORTING
 
Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
Review of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_PresentationReview of an open source unit test tool- Cucumber_Presentation
Review of an open source unit test tool- Cucumber_Presentation
 
ISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture NotesISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture Notes
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
 
Assessing Unit Test Quality
Assessing Unit Test QualityAssessing Unit Test Quality
Assessing Unit Test Quality
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Testing 101
Testing 101Testing 101
Testing 101
 
Testing on frontend
Testing on frontendTesting on frontend
Testing on frontend
 
An introduction to unit testing
An introduction to unit testingAn introduction to unit testing
An introduction to unit testing
 

Último

%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 

Último (20)

%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 

Unit and integration Testing

  • 1. UNIT & INTEGRATION TESTING David Berliner
  • 2. Why Test Types of Tests PHPUnit Writing Tests Getting Stuck In
  • 3.
  • 6. TESTS REDUCE BUGS TESTS ARE GOOD DOCUMENTATION
  • 7. TESTS REDUCE BUGS TESTS ARE GOOD DOCUMENTATION TESTS ALLOW SAFE REFACTORING
  • 8. TESTS REDUCE BUGS TESTS ARE GOOD DOCUMENTATION TESTS ALLOW SAFE REFACTORING TESTS REDUCE THE COST OF CHANGE
  • 9. TESTS REDUCE BUGS TESTS ARE GOOD DOCUMENTATION TESTS ALLOW SAFE REFACTORING TESTS REDUCE THE COST OF CHANGE TESTING FORCES YOU TO THINK
  • 10. TESTS REDUCE BUGS TESTS ARE GOOD DOCUMENTATION TESTS ALLOW SAFE REFACTORING TESTS REDUCE THE COST OF CHANGE TESTING FORCES YOU TO THINK TESTS REDUCE FEAR
  • 11. A study conducted by Microsoft and IBM showed that writing tests can add 15% – 35% to development time but reduce the number of bugs by 40% – 90%. http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf
  • 13. Black Box White Box Unit Integration Functional System Regression Performance Smoke Canary Usability A/B …
  • 14. Black Box White Box Unit Integration Functional System Regression Performance Smoke Canary Usability A/B …
  • 15. UNIT TESTS The goal of unit testing is: 1. to isolate each part of the program, and
  • 16. UNIT TESTS The goal of unit testing is: 1. to isolate each part of the program, and 2. show that the individual parts are correct.
  • 17. UNIT TESTS The goal of unit testing is: 1. to isolate each part of the program, and 2. show that the individual parts are correct. Unit tests have a very narrow and well-defined scope.
  • 19. UNIT TESTS Pro’s: 1. Fast 2. Simple to understand
  • 20. UNIT TESTS Pro’s: 1. Fast 2. Simple to understand 3. Reliable
  • 21. UNIT TESTS Pro’s: 1. Fast 2. Simple to understand 3. Reliable Con’s: 1. Large time investment
  • 22. UNIT TESTS Pro’s: 1. Fast 2. Simple to understand 3. Reliable Con’s: 1. Large time investment 2. Requires maintenance
  • 23. UNIT TESTS A unit test should NOT: 1. Access the network
  • 24. UNIT TESTS A unit test should NOT: 1. Access the network 2. Hit a database
  • 25. UNIT TESTS A unit test should NOT: 1. Access the network 2. Hit a database 3. Use the file system
  • 26. UNIT TESTS A unit test should NOT: 1. Access the network 2. Hit a database 3. Use the file system 4. Call other non-trivial components
  • 27. INTEGRATION TESTS Test the inter-operation of multiple subsystems. Pro’s: 1. Make sure nuts and bolts fit together
  • 28. INTEGRATION TESTS Test the inter-operation of multiple subsystems. Pro’s: 1. Make sure nuts and bolts fit together 2. Test behaviour and infrastructure
  • 29. INTEGRATION TESTS Test the inter-operation of multiple subsystems. Pro’s: 1. Make sure nuts and bolts fit together 2. Test behaviour and infrastructure 3. (tested code) / test % is high
  • 30. INTEGRATION TESTS Test the inter-operation of multiple subsystems. Pro’s: 1. Make sure nuts and bolts fit together 2. Test behaviour and infrastructure 3. (tested code) / test % is high Con’s: 1. Hard to test all critical paths
  • 31. INTEGRATION TESTS Test the inter-operation of multiple subsystems. Pro’s: 1. Make sure nuts and bolts fit together 2. Test behaviour and infrastructure 3. (tested code) / test % is high Con’s: 1. Hard to test all critical paths 2. Harder to localise source of errors
  • 33.
  • 35. 1. Unit Testing Framework written in PHP by Sebastian Bergmann 2. De facto standard 3. Major Frameworks use it (Zend, Cake, Laravel, Symphony etc.)
  • 36. Installation: https://phpunit.de/manual/current/en/installation.html Be sure to install xDebug in order to generate code coverage. Note: PECL no longer supported
  • 38. ORGANISING TESTS - The tests for class Foo are placed in a class FooTest - Most of the time you will inherit from PHPUnit_Framework_TestCase PHPUnit_Extensions_Database_TestCase - Tests are public methods named test* - Inside the test methods, assertion methods such as assertEquals() are used.
  • 39. ORGANISING TESTS Tests should mirror the code being tested. SRC SomeFolder Baz.php Foo.php Bar.php TEST SomeFolder FooTest.php BarTest.php BazTest.php
  • 42. ASSERTIONS assertArrayHasKey() assertClassHasAttribute() assertClassHasStaticAttribute() assertContains() assertContainsOnly() assertContainsOnlyInstancesOf() assertCount() assertEmpty() assertEqualXMLStructure() assertEquals() assertFalse() assertFileEquals() assertFileExists() assertGreaterThan() assertGreaterThanOrEqual() assertInstanceOf() assertInternalType() assertJsonFileEqualsJsonFile() assertJsonStringEqualsJsonFile() assertJsonStringEqualsJsonString() assertLessThan() assertLessThanOrEqual() assertNull ( ) assertObjectHasAttribute() assertRegExp() assertStringMatchesFormat() assertStringMatchesFormatFile() assertSame() assertStringEndsWi th() assertStringEqualsFile() assertStringStartsWi th() assertThat() assertTrue() assertXmlFileEqualsXmlFile() assertXmlStringEqualsXmlFile() assertXmlStringEqualsXmlString()
  • 47. What do you do if the code you want to test is dependent on other components that cannot be used in the test environment?
  • 49. DATABASE TESTING Four stages of a DB test 1. Set up fixture 2. Exercise System Under Test 3. Verify outcome 4. Teardown
  • 50. DATABASE TESTING (CONT) Give it a connection
  • 51. DATABASE TESTING (CONT) Flat XML DataSet
  • 56. • db - Database Skel file and patches • src - Project Code • test/Output - Code coverage • test/SportsBet - Projects Tests • test/TestingCore - Uti l i ties • tools - CI tools including ANT build file