File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Question about JWebUnit / maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Question about JWebUnit / maven" Watch "Question about JWebUnit / maven" New topic
Author

Question about JWebUnit / maven

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Maven 1.1 with JWebUnit 1.4. I'm new to Maven, but how do I set the classpath for the test:compile goal? I have included the JWebUnit dependency in my project.xml file, like so

<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-htmlunit-plugin</artifactId>
<version>1.4</version>
</dependency>

but when I go to run my maven unit test, I get the below compilation errors, all related to jwebunit (or lack thereof). I can see the JAR files that are downloaded. How do I tell maven about them? - Dave

maven -Dtestcase=test.AddToMailingListTest test:single
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.1

build:start:

test:single:
java:prepare-filesystem:

java:init:

java:compile:
[echo] Compiling to /Users/dalvarado/source/assistanceUtility/webapp/target/classes
[echo]
==========================================================

WARNING: maven.compile.target is not set:
using the default value which depends on your JVM

==========================================================


java:jar-resources:

test:prepare-filesystem:

test:test-resources:

test:compile:
[javac] Compiling 1 source file to /Users/dalvarado/source/assistanceUtility/webapp/target/test-classes
[javac] /Users/dalvarado/source/assistanceUtility/webapp/src/test/java/AddToMailingListTest.java:9: package net.sourceforge.jwebunit.junit does not exist
[javac] import net.sourceforge.jwebunit.junit.WebTestCase;
[javac] ^
[javac] /Users/dalvarado/source/assistanceUtility/webapp/src/test/java/AddToMailingListTest.java:11: cannot find symbol
[javac] symbol: class WebTestCase
[javac] public class AddToMailingListTest extends WebTestCase {
[javac] ^
[javac] /Users/dalvarado/source/assistanceUtility/webapp/src/test/java/AddToMailingListTest.java:28: cannot find symbol
[javac] symbol : variable super
[javac] location: class test.AddToMailingListTest
[javac] super.setUp();
[javac] ^
[javac] /Users/dalvarado/source/assistanceUtility/webapp/src/test/java/AddToMailingListTest.java:30: cannot find symbol
[javac] symbol : method getTestContext()
[javac] location: class test.AddToMailingListTest
[javac] getTestContext().setBaseUrl("http://localhost:8080/apps/oit/governor/citizen/assistanceUtility");
[javac] ^


Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
The dependency tag can take a "scope" child tag where you can specify it is needed for test. http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html is a link for maven dependency scopes, but yours would look like this:



Jeff Storey
Software Developer
[url]http://jeffastorey.blogspot.com[/url]
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
THanks for your reply but maybe the version of Maven I'm using (1.1) doesn't support scope. Below is the error I got. Do you know a way to set the classpath maven uses?

__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.1

-------------------------------------------------------------------------------
>> Error parsing project.xml '/Users/dalvarado/source/assistanceUtility/webapp/project.xml'
>> ParseError at [row,col]:[231,13]
Message: Unrecognised tag: 'scope'
-------------------------------------------------------------------------------
BUILD FAILED
-------------------------------------------------------------------------------
Total time : 1 seconds
Finished at : Monday, October 5, 2009 7:22:54 AM MDT
Final Memory : 1M/2M
-------------------------------------------------------------------------------

Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
Ah sorry. I actually started using maven with version 2, so I'm not too sure on this one.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question about JWebUnit / maven
 
Similar Threads
Why is a "classes" dir not created as part of maven build process?
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.
maven and Junit Tests
java.lang.NoSuchMethodError: HandlerMethodResolver
Could not resolve dependencies for maven project