Testing is a software development method to increase software quality. There are several distinct types of testing which vary in granularity and purpose:
- Unit Testing: A test that validates an individual unit of source code, usually a function or a method.
- Integration Testing: A test in which a combination of components are tested together to ensure they are working well as a group. Preferably participating components are unit-tested.
- Acceptance Testing: A test in which a software system is tested as a whole. Acceptance testing declares the standards to which a software system is considered to be working (= accepted).
It’s considered best good practice to automate testing as much as possible. Automatic testing is limited by the computer’s ability to understand what constitutes as a test pass or failure – Therefor, unit-testing is usually the easiest to automate, integration testing can be difficult and acceptance testing is usually performed manually (though unit-testing of smaller components is often a passing criterion).
Testing as a practice has spawned or ignited several development methodologies, such as Agile Development / Extreme Programming and Test-Driven Development / Behavior Driven Development. The guiding principle behind those methodologies is that testing early and often can improve software design by the strength of writing easily testable code. Testable code is usually highly decoupled and re-usable and promotes better interface between code components. Tested code allows for easier refactoring without breaking current behavior (called Regression Testing).
Testing frameworks are software packages that provide a testing environment for running automated tests. Such frameworks usually declare an interface for determining test success, organize tests into groups and provide test helpers such as Mocks ans Stubs.
Testing frameworks for PHP include:
- QUnit, jQuery’s own testing framework
- jsMock, Mock objects framework
Testing as a practice promotes higher software quality and improves software design, however it’s important to keep it in perspective and apply it with common sense. Remember, written code has a purpose, and it’s not solely to pass tests (= The Ultimate Test Failure).
Extra reference materials:
- Wikipedia: Software Testing
- Marcus Baker (author of SimpleTest) on Test Driven Development
- An introduction to unit testing in PHP
To know when the next article is published, please subscribe to new articles using your Email below or follow me on Twitter.