Testing_DocTest: A Unit Test framework for writing tests in your php code docstrings.
Testing_DocTest allows the developer to write unit tests directly in the <code></code> blocs of your PHP functions, classes and class methods.
Testing_DocTest comes with a default runner that will parse all your <code></code> blocs and will run the extracted tests, running tests is as simple as:
$ phpdt /path/to/your/code
There are several advantages in using Testing_DocTest:
- it makes unit tests writing funnier, easier and quicker (there's no infrastructure to setup, you just install the package, write your code examples tests and you're done !);
- it ensures that docstrings are up-to-date by verifying that all examples work as documented;
- it enforces writing of tutorial documentation, liberally illustrated with input-output examples.
Testing_DocTest was maily inspired by the great python doctest module.
$ pear install -f http://testing-doctest.googlecode.com/files/Testing_DocTest-0.2.3.tgz
And to uninstall:
$ pear uninstall Testing_DocTest
Todo list by priority (not exhaustive)
- Integration with other test frameworks (phpt, PHPUnit, xUnit...);
- Better error reports for doctest, instead of Parse error in command line code, try to report the file and line where the test fails (in the docstring);
- Ability to manage test suites (with a "suite:" keyword for example);
- Provide some sort of setup/teardown mechanism, but I'm not sure if it's a good idea... After all you can always include() files in doctests;
- Provide a html runner with a bling-bling gui.