Testing GWT Libraries With Selenium and Maven
In addition, I discovered some javax.servlet.* classes in my JAR after running "mvn package". I believe this is caused by the GWT plugin sucking these in when it compiles my ProxyServlet. I excluded them by adding the maven-jar-plugin.
After doing this, I was able to publish my JAR with all the contents I needed to run Selenium tests against it.
Testing the GWT Library with Selenium
The module that contains the Selenium tests is a WAR project that uses war overlays, Cargo and Selenium RC. You can read about the Maven setup I use for running Selenium tests in Packaging a SOFEA Application for Distribution.
The major difference when testing a JAR (vs. a WAR), is I had to use the maven-dependency-plugin to unpack the JAR so its contents would get included in the WAR for testing. Below is the configuration I used to accomplish this:
Hopefully this will help you develop GWT libraries and run Selenium tests against them. If you have any suggestions for simplifying this configuration, please let me know.
NOTE: I did considering a couple of other options for running Selenium tests against our GWT library:
- Add something to the existing project that 1) creates a WAR and 2) fires up Cargo/Selenium in a profile to test it.
- Create the tests in a GWT (war) project that includes widgets from the library.
I decided on the solution documented above because it seemed like the best option.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)