Testing Untestable Code

Stephan Hochdörfer (bitExpert AG)
Location: E144
Average rating: ***..
(3.47, 15 ratings)

Testing software applications with the help of unit testing facilities is an widely-adopted standard in the software development industry today. Even the PHP community provides the necessary tools like PHPUnit or SimpleTest to be able to automate testing of PHP applications. Unfortunately there exist legacy applications that are not testable by their internal design. In some rare cases even software written today is not well designed to meet the necessary requirements for automated tests. Testing an single component in isolation is not possible in those cases due to their dependencies on other components. This often leads to the point of manual testing which is rather cost-intense and error-prone. In the first part of the session it is shown how the dynamic nature of PHP itself can be used to manipulate existing dependencies to be able to test a single part of the application on its own. To a certain extent the techniques that are shown allow to test a wide range of hard to test pieces of code. To be able to test untestable code an additional layer of abstraction is introduced in the second part of the session. By using that layer it is shown that it is possible to test any legacy code application by transforming the parts-to-test into testable code fragments that a unit testing facility can deal with without changing any line of the original source code.

Photo of Stephan Hochdörfer

Stephan Hochdörfer

bitExpert AG

Stephan Hochdörfer is co-founder and department manager of Research Labs at bitExpert AG in Mannheim, Germany. His primary focus is web development with PHP and generative programming techniques.


For information on exhibition and sponsorship opportunities at the conference, contact Sharon Cordesse at (707) 827-7065 or scordesse@oreilly.com.

View a complete list of OSCON contacts