Benjamin Eberlei »
05 June 2009 »
in Practices and Tools »
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.
Manuel Pichler and Sebastian Nohn »
22 May 2009 »
in Practices and Tools »
This is an abstract for a chapter from a book on Quality Assurance in PHP Projects.
One of the most important events in large and distributed team projects is the integration of all parts of the software system into a release. Often incompatibilities and hard-to-detect errors surface at that very moment and can harm the success of the project. The remedy for this problem is the practice of Continuous Integration: a merge of all parts of the system as often as possible during the lifecycle of the project.
In this case study, we will take a look into the preconditions to start with Continuous Integration as well as the procedural and technical rationales of this approach. We will take a look at entering Continuous Integration in PHP projects with phpUnderControl, a customization of the popular and established Continuous Integration server software CruiseControl.
Beyond Continuous Integration, this case study introduces the reader to the principles of Static Testing and how to instrument it to gain a better quality. Amongst other tools, the reader will learn how to successfully use tools such as PHP_CodeSniffer, PHP_Depend and phpcpd for Static Code Analysis.
In conclusion, advanced usage scenarios of the discussed tools will be discusses with a particular focus on how to foster further principles of Agile Software Development methodologies and how to solve discrepancies with other targets of agile methodologies.
Manuel Pichler is the creator of phpUnderControl, PHP_Depend, and phpmd. Sebastian Nohn is the Team Lead Quality Assurance at Ligatus GmbH.
Michael Lively Jr. »
27 March 2009 »
in Practices and Tools »
This is an abstract for a chapter from a book on Quality Assurance in PHP Projects.
Proper interaction with relational databases is incredibly important in most pieces of software. The importance of this interaction is underscored by the fact that many software architectures have at least one entire layer or system devoted to data persistence and data loading. When dealing with critical data in enterprise level applications it becomes even more important to make sure your data is being stored and retrieved correctly.
As responsible developers, one of our goals should be to test database interaction and test it well. To help achieve this goal, we will take a close look at tools and techniques that can be used with projects of any size to help create reliable tests capable of validating your database interaction.
The discussion will begin with various techniques for testing your database layer. The focus will then move toward the functionality in the database extension for PHPUnit. Then, utilizing the tools provided in the database extension, examples will be given of how to create basic tests validating that the database is correctly manipulated and data from your database is successfully retrieved. This will be followed by an in depth discussion of "best practices" that can be utilized when you are developing "database aware" fixtures and tests.
Once the ground work is laid, we will look at how all of these tools and techniques can be utilized in both your unit tests and functional tests.
Michael Lively Jr. is the Lead PHP Developer for Selling Source, LLC.
Brian Shire »
06 March 2009 »
in Practices and Tools »
This is an abstract for a chapter from a book on Quality Assurance in PHP Projects.
Incorrect application functionality is a detriment to any project, but poor performance and scalability can often lead to end-user dissatisfaction and exorbitant hardware expenses.
In the case of modern web application, expectations have made it necessary to provide responses within as little as 100 to 500 milliseconds. This puts a tremendous burden on not only achieving excellent performance, but maintaining consistent performance as code changes and new features are added.
We will review a variety of tools that can be used to test performance and scalability. While the stack will be assumed to be Linux, Apache, MySQL and PHP (LAMP), the basic skills and tools can be applied to a variety of systems (and often the ability to correctly test different system components is itself a valid test case).
An initial emphasis will be on the most basic end-to-end testing of the entire request and response cycle, but later will detail smaller benchmarks and developing custom tool sets once you require more precision. Operating System metrics are also key to ensuring an application's scalability and performance, so tools such as sar, strace, and oprofile will be covered. Because performance testing has unique requirements and challenges we will cover methodologies to correctly implement performance tests, benchmarks and the pitfalls to avoid. These include the short term assurance of accuracy, reproducing results, as well as long term goals and how to balance future expectations, growth, and priorities of an entire product or service.
Brian Shire is Facebook's technical lead for PHP internals and a developer for the Alternative PHP Cache (APC).