Merge pull request #70 from padraic/amend/testing-tools

Added Complementary Testing Tools section (separate Selenium/add Mockery...
This commit is contained in:
Phil Sturgeon
2012-07-10 12:30:17 -07:00
3 changed files with 18 additions and 7 deletions

View File

@@ -4,20 +4,19 @@ isChild: true
## Test Driven Development
Unit Testing is a programatical approach to ensure functions, classes and methods are working as
expected, from the point you build them all the way through to the development cycle. By checking
Unit Testing is a programmatical 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 you can check internal
parameter values for even better test coverage.
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.
When you create a class or function you should create a unit test for it. At a very basic level you should
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.
This will help ensure that when you make changes to this class or function later on in the development
cycle that the old functionality continues to work as expected. The only alternative to this would be
var_dump() in a test.php, which is no way to build an application - large or small.
The other use for unit tests is contributing to open source. If you can write a test that shows broken
functionality, then fix it, and show the test working, patches are much more likely to be accepted. If
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

View File

@@ -12,7 +12,7 @@ is Behat, which is inspired by Ruby's [Cucumber](http://cukes.info/) project and
for describing feature behavior.
With SpecBDD, you write specifications that describe how your actual code should behave. Instead of testing
a function or method, you are describing how that function or method should behave. This framework is inspired
a function or method, you are describing how that function or method should behave. PHP offers the PHPSpec framework for this purpose. This framework is inspired
by the [RSpec project](http://rspec.info/) for Ruby.
### BDD Links

View File

@@ -0,0 +1,12 @@
---
isChild: true
---
## Complementary Testing Tools
Besides individual testing and behaviour driven frameworks, there are also a number of generic frameworks and helper libraries useful for any preferred approach taken.
### Tool Links
* [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)
* [Mockery](https://github.com/padraic/mockery) is a Mock Object Framework which can be integrated with [PHPUnit](http://phpunit.de/) or [PHPSpec](http://www.phpspec.net/)