Dan's thoughts
Using the MakeGood plugin in Eclipse PDT
In the Internal Tools department here at Epiphany, we’ve adopted Eclipse PDT as our IDE of choice for PHP development. As well as being one of the best free IDEs for PHP development out of the box, it also provides an excellent plugin framework with a wide range of extensions from various providers.
One of these which has proved extremely useful is the MakeGood test runner by Japanese developers Piece Framework. This tool integrates unit test running with the IDE allowing tests to be run from the same environment as the code is written.
Setup
Installing the plugin is easy, thanks to the plugin system implemented by Eclipse. An install link on the website can be dragged and simply dropped into Eclipse to install the plugin.
Configuring it to work is less straightforward and depends largely on the general environment configuration for PHP development in Eclipse. PHP and a database are required on the development machine (on Windows I use XAMPP) and Eclipse must be configured to know about the PHP executable. MakeGood has its own configuration section in which the testing framework and location of tests can be specified.
For the particular project we’ve been working on, we were using CakePHP which requires a couple of directories to be specified. It also seems important to make sure that the Build and Include paths are set up correctly. It took quite a bit of experimenting with different settings to make it work and the errors produced when the settings are incorrect are not the most intuitive. The developers themselves do provide a good user guide to the system but there don’t seem to be many online sources of solutions to the configuration problems.
Usage
Once the tool is configured, it is extremely easy to use. It provides a view panel showing test progress, timings and a list of passes and failures and it also integrates itself into a number of contextual menus and provides some handy keyboard shortcuts – useful for me as I like to keep both hands on the keyboard when I’m working.
The main commands I’ve found useful are “Run all tests in file”, “Rerun test” and “Run all tests in context”. The first and second are fairly self-explanatory, whilst the third will run the test at the current cursor position (if there is one). This is useful because test runs can be time consuming and we often only want to run the test we’re currently concerned with, rather than the whole set.
If, having run a test, there are any failures, the plugin will put error markers in the test code at the lines causing the failure so it’s easy to see which assertions are failing. Even better, if there is an exception (rather than an assertion failure) a marker will appear where the exception occurred (being PHP this is not always 100% accurate but it’s not bad.)
Conclusion
Although a little tricky to get working this plugin is well worth the effort. It’s a big timesaver to be able to run tests from the IDE with a keystroke and to see test failures in-place with markers. I’d go so far as to say it’s become something I couldn’t live without, or at least wouldn’t want to.
What are your thoughts on this? Let me know by leaving a comment below.


