SlideShare a Scribd company logo
Back to basics




            Sebastian Marek
What is a unit test?


In computer programming, unit testing is a method by
which individual units of source code are tested to
determine if they are fit for use. A unit is the smallest
testable part of an application.
                                http://en.wikipedia.org/wiki/Unit_testing
For whom?



Unit tests are typically written and run by software
developers to ensure that code meets its design and
behaves as intended.
                           http://en.wikipedia.org/wiki/Unit_testing
What for?

The goal of unit testing is to isolate each part of the
program and show that the individual parts are correct. A
unit test provides a strict, written contract that the piece
of code must satisfy. As a result, it affords several
benefits. Unit tests find problems early in the
development cycle.
                                http://en.wikipedia.org/wiki/Unit_testing
Benefits

● Facilitates change
● Simplifies integration

● Living documentation

● Early design
Installing PHPUnit

#> pear channel-discover pear.phpunit.de
#> pear channel-discover components.ez.no
#> pear channel-discover pear.symfony-project.com

#> pear install phpunit/PHPUnit
#> phpunit –version
PHPUnit 3.5.11 by Sebastian Bergmann.
Managing tests
Writing tests

● assertions
● testing exceptions

● data providers

● test dependencies

● test fixtures

● stubs

● mock objects
Logging results

● verbose mode
● testdox format

● test results

● code coverage results
PHPUnit configuration file

● bootstrap file
● process isolation

● including and excluding files for code coverage

● logging
Resources

●   http://www.phpunit.de/manual/current/en/index.html
Q&A




?

More Related Content

PDF
Static code analysis
ODP
Software testing tools
PPTX
A year of SonarQube and TFS/VSTS
PPT
Nunit
PPT
Unit testing
PDF
User story workflow (eng)
PDF
Software testing tools
PPTX
Java Code Quality Tools
Static code analysis
Software testing tools
A year of SonarQube and TFS/VSTS
Nunit
Unit testing
User story workflow (eng)
Software testing tools
Java Code Quality Tools

What's hot (19)

PDF
Open Source Software Testing Tools
PPTX
Testing JavaScript Applications
PPTX
Regression Testing with Symfony
PDF
Уроки, полученные при проведении автоматизированного приемочного тестирования
PDF
A journey with Target Platforms
PDF
Checkstyle wikipedia
PPT
Software Testing - Tool support for testing (CAST) - Mazenet Solution
PDF
An Introduction to Unit Test Using NUnit
PDF
TDD Workshop UTN 2012
PPTX
JavaScript Unit Testing
PPTX
Unit Testing Using N Unit
PDF
Quality for developers
PDF
Test automation design patterns
PPTX
Project Onion unit test environment
PPTX
Framework
PDF
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
PPTX
Track code quality with SonarQube - short version
PPT
Automated Unit Testing and TDD
PDF
Efficient mobile automation
Open Source Software Testing Tools
Testing JavaScript Applications
Regression Testing with Symfony
Уроки, полученные при проведении автоматизированного приемочного тестирования
A journey with Target Platforms
Checkstyle wikipedia
Software Testing - Tool support for testing (CAST) - Mazenet Solution
An Introduction to Unit Test Using NUnit
TDD Workshop UTN 2012
JavaScript Unit Testing
Unit Testing Using N Unit
Quality for developers
Test automation design patterns
Project Onion unit test environment
Framework
Project Management: Burn-Down Chart / OrangeHRM Project MOD (eng)
Track code quality with SonarQube - short version
Automated Unit Testing and TDD
Efficient mobile automation
Ad

Similar to Back to basics - PHPUnit (20)

PDF
PChomePay unit test basic
PDF
Unit and integration Testing
PDF
Systematic Unit Testing
PDF
Unit testing in PHP
PDF
PHPUnit & Continuous Integration: An Introduction
KEY
Unit Testing Your Application
PPT
Unit testing php-unit - phing - selenium_v2
PDF
Test Driven Development
PDF
What Is Unit Testing_ A Complete Guide With Examples.pdf
ZIP
Test
PPTX
PHPUnit: from zero to hero
PDF
Cursus phpunit
PDF
What Is Unit Testing A Complete Guide With Examples.pdf
PDF
Unit testing - An introduction
PDF
Unit testing (eng)
PPTX
Unit Testng with PHP Unit - A Step by Step Training
PDF
How Unit Testing Strengthens Software Reliability
KEY
Client Side Unit Testing
PChomePay unit test basic
Unit and integration Testing
Systematic Unit Testing
Unit testing in PHP
PHPUnit & Continuous Integration: An Introduction
Unit Testing Your Application
Unit testing php-unit - phing - selenium_v2
Test Driven Development
What Is Unit Testing_ A Complete Guide With Examples.pdf
Test
PHPUnit: from zero to hero
Cursus phpunit
What Is Unit Testing A Complete Guide With Examples.pdf
Unit testing - An introduction
Unit testing (eng)
Unit Testng with PHP Unit - A Step by Step Training
How Unit Testing Strengthens Software Reliability
Client Side Unit Testing
Ad

More from Sebastian Marek (16)

PDF
The Journey Towards Continuous Integration
PDF
CodeClub - Teaching the young generation programming
PDF
Praktyczne code reviews - PHPConPl
PDF
Managing and Monitoring Application Performance
PDF
Ten Commandments Of A Software Engineer
PDF
Continuous Inspection: Fight back the 7 deadly sins of a developer!
PDF
Test your code like a pro - PHPUnit in practice
PDF
Effective code reviews
PDF
Effective code reviews
PDF
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PPTX
Ten Commandments Of A Software Engineer
PDF
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PPTX
Magic behind the numbers - software metrics in practice
ODP
Back to basics - PHP_Codesniffer
ODP
Sonar - the ring to rule them all
ODP
vfsStream - effective filesystem mocking
The Journey Towards Continuous Integration
CodeClub - Teaching the young generation programming
Praktyczne code reviews - PHPConPl
Managing and Monitoring Application Performance
Ten Commandments Of A Software Engineer
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Test your code like a pro - PHPUnit in practice
Effective code reviews
Effective code reviews
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
Ten Commandments Of A Software Engineer
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
Magic behind the numbers - software metrics in practice
Back to basics - PHP_Codesniffer
Sonar - the ring to rule them all
vfsStream - effective filesystem mocking

Recently uploaded (20)

PPTX
Machine Learning_overview_presentation.pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
cuic standard and advanced reporting.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Machine Learning_overview_presentation.pptx
Getting Started with Data Integration: FME Form 101
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
1. Introduction to Computer Programming.pptx
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
Per capita expenditure prediction using model stacking based on satellite ima...
cuic standard and advanced reporting.pdf
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
Assigned Numbers - 2025 - Bluetooth® Document

Back to basics - PHPUnit

  • 1. Back to basics Sebastian Marek
  • 2. What is a unit test? In computer programming, unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. http://en.wikipedia.org/wiki/Unit_testing
  • 3. For whom? Unit tests are typically written and run by software developers to ensure that code meets its design and behaves as intended. http://en.wikipedia.org/wiki/Unit_testing
  • 4. What for? The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. Unit tests find problems early in the development cycle. http://en.wikipedia.org/wiki/Unit_testing
  • 5. Benefits ● Facilitates change ● Simplifies integration ● Living documentation ● Early design
  • 6. Installing PHPUnit #> pear channel-discover pear.phpunit.de #> pear channel-discover components.ez.no #> pear channel-discover pear.symfony-project.com #> pear install phpunit/PHPUnit #> phpunit –version PHPUnit 3.5.11 by Sebastian Bergmann.
  • 8. Writing tests ● assertions ● testing exceptions ● data providers ● test dependencies ● test fixtures ● stubs ● mock objects
  • 9. Logging results ● verbose mode ● testdox format ● test results ● code coverage results
  • 10. PHPUnit configuration file ● bootstrap file ● process isolation ● including and excluding files for code coverage ● logging
  • 11. Resources ● http://www.phpunit.de/manual/current/en/index.html
  • 12. Q&A ?