mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-13 17:23:58 +02:00
Merge pull request #84 from chartjes/gh-pages
Reworking of testing section
This commit is contained in:
@@ -4,10 +4,18 @@ isChild: true
|
||||
|
||||
## Test Driven Development
|
||||
|
||||
Unit Testing is a programmatical approach to ensure functions, classes and methods are working as
|
||||
From Wikipedia:
|
||||
|
||||
>> Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards. Kent Beck, who is credited with having developed or 'rediscovered' the technique, stated in 2003 that TDD encourages simple designs and inspires confidence
|
||||
|
||||
There are several different types of testing that you can do for your application
|
||||
|
||||
### Unit Testing
|
||||
|
||||
Unit Testing is a programming approach to ensure functions, classes and methods are working as
|
||||
expected, from the point you build them all the way through the development cycle. By checking
|
||||
values going in and out of various functions and methods, you can make sure the internal logic is
|
||||
working correctly. By using Dependecy Injection and building "mock" classes and stubs you can verify that dependencies are correctly used for even better test coverage.
|
||||
working correctly. By using Dependency Injection and building "mock" classes and stubs you can verify that dependencies are correctly used for even better test coverage.
|
||||
|
||||
When you create a class or function you should create a unit test for each behaviour it must have. At a very basic level you should
|
||||
make sure it errors if you send it bad arguments and make sure it works if you send it valid arguments.
|
||||
@@ -19,12 +27,31 @@ The other use for unit tests is contributing to open source. If you can write a
|
||||
functionality (i.e. fails), then fix it, and show the test passing, patches are much more likely to be accepted. If
|
||||
you run a project which accepts pull requests then you should suggest this as a requirement.
|
||||
|
||||
PHPUnit is the most popular and has become a de facto standard with its popular adoption amongst [PHP
|
||||
frameworks][phpfws] and [Composer][composer] component developers, but there are a few alternatives around.
|
||||
[PHPUnit](http://phpunit.de) is the de-facto testing framework for writing unit tests for PHP
|
||||
applications, but there are several alternatives
|
||||
|
||||
* [PHPUnit](http://phpunit.de/)
|
||||
* [SimpleTest](http://simpletest.org)
|
||||
* [Enhance PHP](http://www.enhance-php.com/)
|
||||
* [PUnit](http://punit.smf.me.uk/)
|
||||
|
||||
[phpfws]: /#libraries_and_frameworks
|
||||
[composer]: /#composer_and_packagist
|
||||
### Integration Testing
|
||||
|
||||
From Wikipedia:
|
||||
|
||||
>> Integration testing (sometimes called Integration and Testing, abbreviated "I&T") is the phase in software testing in which individual software modules are combined and tested as a group. It occurs after unit testing and before validation testing. Integration testing takes as its input modules that have been unit tested, groups them in larger aggregates, applies tests defined in an integration test plan to those aggregates, and delivers as its output the integrated system ready for system testing.
|
||||
|
||||
Many of the same tools that can be used for unit testing can be used for integration testing as many
|
||||
of the same principles are used.
|
||||
|
||||
### Functional Testing
|
||||
|
||||
Sometimes also known as acceptance testing, functional testing consists of using tools to create automated
|
||||
tests that actually use your application instead of just verifying that individual units of code are behaving
|
||||
correctly and that individual units can speak to each other correctly. These tools typically work using real
|
||||
data and simulating actual users of the application.
|
||||
|
||||
#### Functional Testing Tools
|
||||
|
||||
* [Selenium](http://seleniumhq.com)
|
||||
* [Mink](http://mink.behat.org)
|
||||
* [Codeception](http://codeception.com) is a full-stack testing framework that includes acceptance testing tools
|
||||
|
@@ -19,4 +19,4 @@ by the [RSpec project](http://rspec.info/) for Ruby.
|
||||
|
||||
* [Behat](http://behat.org/) is inspired by Ruby's [Cucumber](http://cukes.info/) project
|
||||
* [PHPSpec](http://www.phpspec.net/) the SpecBDD framework for PHP
|
||||
* [Selenium](http://seleniumhq.org/) is a browser automation tool, which can be [integrated with PHPUnit](http://www.phpunit.de/manual/3.1/en/selenium.html)
|
||||
* [Codeception](http://www.codeception.com) is a full-stack testing framework that uses BDD principles
|
||||
|
Reference in New Issue
Block a user