Matt RaibleMatt Raible is a Web Architecture Consultant specializing in open source frameworks.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Maven, Cargo, Struts 2 and working outside

Life is pretty good today. I'm currently working outside - in a courtyard area near the 30th Street Station in Philadelphia. There's 4 restaurants in the courtyard, all with outside seating. It's 72°F and beautiful. I plan to work for a few hours, then hop on the 5:00 train to NYC.

The reason I'm writing this post is to point out a few useful tidbits I've picked up today. First of all, Andrew Glover has written a developerWorks article on Cargo titled In pursuit of code quality: Repeatable system tests. In this article, he shows how to use jWebUnit as well as DbUnit. While the article uses Ant, Andrew mentions that Cargo also works with Maven (and has a Java API too).

Equinox uses jWebUnit, Maven and Cargo, but it doesn't currently support running Cargo from Maven. The major reason for this is I tried to automate running jWebUnit tests from the antrun-plugin and couldn't get it to work (I only tried for 10 minutes). Does anyone have any insight for including jWebUnit tests alongside your regular tests, excluding them from Maven's "test" phase, and running them in the "integration-test" phase? The good news is AppFuse 2.0 uses Maven as well, and we have Cargo + Canoo WebTest working just fine. BTW, did you know that Mergere’s Maestro (a free product) includes Equinox? If you're looking to learn Continuum and you're familiar with Equinox, downloading Maestro is probably a good start.

Speaking of web testing, I've been playing with Selenium lately. I was able to easily integrate it into Thomas and I's Spring 2.0 Kickstart application thanks to these Maven and Selenium integration instructions. The only issues I've run into so far are specifying an initial URL that works in Selenium core as well as Selenium IDE and integrating Selenium with CruiseControl. If you're interested in learning more about Selenium checkout Catching up with Selenium on InfoQ.

Last, but certainly not least, Struts 2.0 was released today. I've already integrated this into the Struts version of AppFuse 2.0. If you like living on the bleeding, you could dig in and try it out today. Unfortunately, I haven't had a chance to put a whole lot of documentation together yet. I hope to install Confluence on appfuse.org sometime this week to start documenting how bad-ass AppFuse 2.0 will be ;-).

Speaking of 2.0 releases, wasn't Spring 2.0 Final supposed to be released yesterday?

Posted in Java at Sep 27 2006, 11:40:42 AM MDT 7 Comments
Comments:

It is possible to run both unit and integration tests in the same module with Maven. The trick is realizing that you're allowed only one testSourceDirectory, then playing with includes and excludes to get the right set of tests to run in each phase.

You can see an example of this in the integration tests for the Shale UseCases example app: pom.xml

We configure the Surefire plugin to exclude (for example) **/systest/** during the 'test' phase, then bind another execution of surefire to the integration-test phase, with the pattern reversed.

The Cargo-related properties you see being passed in the second Surefire execution are for the CargoTestSetup class. This is a convenience JUnit TestSetup class that uses Cargo to start and stop a container for the integration tests. (Despite being part of the Shale Test module, CargoTestSetup has no dependencies on JSF, so you can use it in any project.)

Alternately, you could bind executions of Cargo's m2 plugin to the pre- and post- integration test phases to start and stop a container.

Rumor has it this will be much easier with Maven 2.1, which will support something like src/it/java for integration tests in addition to src/test/java for unit tests.

PS: I'm glad you found the Maven-and-Selenium page helpful. :)

Posted by Wendy Smoak on September 27, 2006 at 02:33 PM MDT #

Hi Matt, The 26th should have been considered as an almost precise estimate. We want to be sure that we ship Spring 2.0 with the usual quality instead of just releasing on the exact date mentioned in the interview; no matter what. It is a matter days though before it's going to be released so stay tuned! regards, Alef

Posted by Alef Arendsen on September 27, 2006 at 03:04 PM MDT #

Seems like it will take 4 more days: http://www.springframework.org/countdown

Posted by Wim Deblauwe on September 28, 2006 at 08:04 AM MDT #

Matt, Can you comment about how you view Selenium, now that you've been messing around with it, especially in comparison to Canoo Web Test (which you've stated previous preference for) and JWebUnit? Have you checked into running JWebUnit tests in Selenium (its supported in JWebUnit's SVN...)? thanks, Zach

Posted by Zach Lendon on October 01, 2006 at 09:03 PM MDT #

Zach - I really like Selenium, especially since it runs your tests in the browser. I haven't checked out jWebUnit with Selenium, but it sounds interesting.

Posted by Matt Raible on October 26, 2006 at 02:17 PM MDT #

Having problems setting up a Struts 2, Maven-based project. Could you please post a link to an example pom?

Posted by Spizzy on November 28, 2007 at 05:41 AM MST #

Spizzy - the Struts Maven Archetypes should help.

Posted by Matt Raible on November 28, 2007 at 09:26 AM MST #

Post a Comment:
  • HTML Syntax: Allowed