Thursday, September 10, 2009

Running ScalaTest BDD Tests from Eclipse

At Bizo, we're using Scala for a few things here and there. While investigating testing approaches for Scala, I came across ScalaTest and its Behavior Driven Development (BDD) spec approach.

While its a small thing, I really like the sentence-based it "should do this and that" aspect of the spec approach. You get great readability compared to traditional "testDoThisAndThat" method names.

However, a large downside to the spec approach is that spec tests cannot, on their own, be easily, one-keyboard-shortcut run from within Eclipse. The built-in Eclipse JUnit test runner does not understand the describe/it-based test structure.

To solve this, I wrote a class that can be used with JUnit's "RunWith" annotation to bridge the gap between JUnit and ScalaTest. Its not perfect, but you get back the one-shortcut/greenbar runner in Eclipse. So I can definitely see it being handy if we decide to do any spec-based testing here at Bizo.

Wednesday, September 9, 2009

GWT hosted mode on snow leopard

One of the first things I noticed after installing Snow Leopard was that GWT hosted mode no longer worked. You'll see the message "You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X." After spending about 10 minutes convincing myself that I was in fact using jdk1.5 for eclipse, ant, etc., and like, wasn't this working last week? I finally looked at the jdk symlinks in JavaVM.framework and figured out that 1.5 was just pointing to 1.6... interesting.

There was some discussion on the GWT group, along with a proposed fix of downloading someone's packaged leopard JDK and changing the symlinks. Not a great fix...

The Lombardi development team has come up with a great work-around.

I put together a jar with the modified BootStrapPlatform code (contains both .class and .java), or get just the src here.

Here are some step-by-step instructions for getting this working in Eclipse:

  1. add the gwt-dev-mac-snow jar to your Java Build path.

  2. in Java Build Path -> Order and Export, move the gwt-dev-mac-snow jar above the GWT SDK Library.

  3. go to Run->Run Configurations. In Web Applications->(your GWT project), click on Arguments, then add -d32 under VM arguments.

That's it! You should now be able to run GWT hosted mode on Snow Leopard.