> Hi ,
> 
> I am using Maven for the first time for 'Unit Testing'. I am 
> not very clear about how it exactly works. As far as I know, 
> Maven has a in built plugin for JUnit and we need to provide 
> the <unitTestSourceDirectory> in Project.xml. However if 
> for,e.g., SampleTest.java is expected to test 
> SampleMaven.java, then how the individual methods are going 
> to be tested ? How are we going to pass the parameters ? 
> shall we call every method individually ?

My experience using Maven for unit testing has been positive.   It looks
like below you don't have your MavenTest class anywhere in your classpath.  

This is the way I've used Maven for unit testing (but there might be other
ways as well).

I put all of my application source in the project.xml
project.build.sourceDirectory tag (e.g.
<sourceDirectory>src/java</sourceDirectory>.)

I put all of my unit tests source files in the project.xml
project.build.unitTestSourceDirectory tag (e.g.
<unitTestSourceDirectory>src/tests</unitTestSourceDirectory>.)

Then I do "maven test:test" and all of the unit tests are executed!  In this
case the unit tests all run against the code found in src/java.

You can pop up the Junit swing gui too with "maven test:ui" I believe and
run each one individually.  

One must know, however, how to write Junit tests.  If you don't I would
suggest you read the Junit documentation.  

Good luck - Steve

> I am sorry for asking such a basic question but I have never 
> worked in this regard. I tried to use Unit testing feature 
> but getting some errors as below:
> 
> test:test-resources:
> 
> test:compile:
>     [javac] Compiling 1 source file to 
> D:\SampleMaven\target\test-classes
> 
> test:test:
>     [junit] dir attribute ignored if running in the same VM
>     [junit] Running MavenTest
>     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>     [junit] [ERROR] TEST MavenTest FAILED
> 
> BUILD FAILED
> File...... file:/C:/Documents and 
> Settings/104487/.maven/plugins/maven-test-plug
> in-1.3/
> Element... fail
> Line...... 99
> Column.... 54
> There were test failures.
> Total time:  21 seconds
> 
> Log under 'testreports' says :
> java.lang.ClassNotFoundException: MavenTest
>       at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
> 
> 
> Attached with this is my Project.xml, Source and Test files.
> 
> 
> 
> Thanks a lot in advance,
> Yogesh
> 
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to