Wednesday, March 4, 2009

PHPUnit Test Case Builder for Chisimba

I have started work on a very nifty module for Chisimba that will allow any Chisimba module developer to create a complete PHPUnit test case for their module.

The Chisimba PHPUnit Test Case Builder generates PHP test case classes for any Chisimba module.

Module Outputs
It implements a code pattern analyzer that classifies code into logical groups like Data Management, Utility, Callback and Display methods.

These code groupings are then transferred to a single PHPUnit skeleton class divided into the logical associations. All the standard, known asserts are added to the code making it ready for phpunit to process on the fly.

It creates a file with the following checks:
  • Uses the register.conf file to check against the current environment for dependencies.
  • Uses the live database structures to construct wrapper code for individual table field checks.
  • The Data Management Tests are broken down logically into Add/Edit/Delete sections and uses the table field checks to verify expected data (Uses table field data type to produce test data)
This provides a solid base for the developer to start unit testing from as the last step would be to peruse the skeleton and logically select the proper assertions to use. The benefits of having logically inclined test cases include the ability to make core changes and see the rippling effects, identify possible problematic areas (e.g. fields as arguments in insert/edit that do not match up to database field names), identify optimization targets and improve overall integrity of your module.

Future Plans
For display/ui testing, there are plans to integrate and automate selenium test code generation as PHPUnit already has some form of support for this.

Stay tuned for progress.

No comments:

Post a Comment