Unit Testing Bad Practices by Example

Benjamin Eberlei » 05 June 2009 » in Practices and Tools » 0 Comments

This is an abstract for a chapter from a book on Quality Assurance in PHP Projects.

Although Unit Testing is a recommended practice for any software project, care has to be exercised such that testing yields the desired benefits. Bad programming practices in both test code and production code can make Unit Testing a nightmare. Maintenance of an overly complex test suite can easily become a burden to the project team.

Situations of hard to maintain test code can have extremely negative outcomes for project quality. Programmers start to ignore tests, because of their inconclusive description of what is going wrong. New features might not be tested at all, because writing tests for the current architecture considerably extends development time. In the end the project manager might decide to stop Unit Testing alltogether, because the costs outweight the benefits.

Bad practices of Unit Testing manifest in so called "Test Smells". These are an early indicator of problems for long-run maintainability and utility of a project test suite. To constantly derive a benefit from Unit Tests, a commitment for high quality tests has to be made.

This case study will discuss Unit Testing bad practices and well as Test Smells and gives hints on how to avoid them. For each test smell, examples are shown from well-known PHP Open Source projects. As a result, the reader should be aware of the possible pitfalls of Unit Testing and that any test code requires the same care that is put into production code.

Benjamin Eberlei is a Project Lead with direkt effekt GmbH and contributes to the Zend Framework and other Open Source projects.

Trackback specific URI for this entry

0 Comments to "Unit Testing Bad Practices by Example"

Display comments as (Linear | Threaded)
  1. No comments

1 Trackback to "Unit Testing Bad Practices by Example"

  1. Quality Assurance in PHP Projects 04/11/2009 at 09:36
    It has been quiet on this website since we posted the last contributed chapter abstract in June and it is time to give you an update. But first, allow me to refresh your memory on the list of contributed chapters:Case Studies on QA Processes in CompaniesQ

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.


Submitted comments will be subject to moderation before being displayed.