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?
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 #
Posted by Alef Arendsen on September 27, 2006 at 03:04 PM MDT #
Posted by Wim Deblauwe on September 28, 2006 at 08:04 AM MDT #
Posted by Zach Lendon on October 01, 2006 at 09:03 PM MDT #
Posted by Matt Raible on October 26, 2006 at 02:17 PM MDT #
Posted by Spizzy on November 28, 2007 at 05:41 AM MST #
Posted by Matt Raible on November 28, 2007 at 09:26 AM MST #