Testing in Play's Eclipse Plugin

Published on 11 March 2010

In Play’s Eclipse plugin, I just added a simple integration with the test framework. Currently, all it does is opening the test page directly within Eclipse.

The obvious next step would be that, in case of a failure typically, links from the page brings you directly to your code at the correct line. That would be also very useful for error pages, just like Guillaume did in his Textmate integration. So I did some research, what is it possible to do with Eclipse?

I found a very old bug, opened in 2001, to support opening files directly from the command line. After nearly 10 years the bug is finally fixed: it’s in the not-yet-released 3.6 version of Eclipse. It’s such a basic feature it’s surprising they couldn’t do it earlier, but at least they eventually did it. So with a nightly build of Eclipse, you can open files like this: <pre id="comment_text_72">eclipse -name Eclipse –launcher.openFile <qualified file name></pre> That’s the most important piece already in place, so it’s good news. But that’s not enough. To jump right to the error, you need to be able to open the file at a given line number. You don’t want to have to search in your code for the line responsible for the error. So I opened bug 305336. Looking at the patch for bug 4922, adding the line number seems trivial to do. I’ll probably submit a patch and cross my fingers to have it in 3.6 before it’s released.

The last piece we would need is Eclipse registering itself as a protocol handler. That would allow us to insert URLs such as:

eclipse://open?url=file://<qualified file name>

Again, I opened a bug (#305345). It’s not as critical as the other items because this one can be created manually. For Windows there’s a key to add to the registry, for Gnome it’s a key in gconf and for OSX I’m sure there is something similar. Of course, it would be better if it Eclipse registered itself so the user won’t have to mess with his registry.

TAGS: eclipse  Misc  play framework