You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Aaron Freeman <aa...@gmail.com> on 2006/05/01 23:15:09 UTC

Test dependencies

One of our projects uses some mock objects for running some JUnit
tests. These objects were put in the appropriate packages under the
src/test folder in one of the sub-modules. Now we want to use these
mock objects in the JUnit tests of one of the other sub-modules.
However, when Maven tries to compile the test classes in the second
sub-module it says it can't find the mock objects. I assume this is
because you can't reference classes in the src/test section of another
project. Is this true? Is there any way to change this? Or should we
pull all the mock objects into a separate sub-module and have both the
other modules reference them there?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Test dependencies

Posted by Wayne Fay <wa...@gmail.com>.
This Test Framework jar that Jeff is speaking of should use the
<type>test-jar</type> in your pom packaging.

If you search the website and User list archive, you will find some
more details, examples, documentation, etc for test-jar's.

Wayne

On 5/1/06, Jeff Jensen <je...@upstairstechnology.com> wrote:
> Quoting Aaron Freeman <aa...@gmail.com>:
>
> > One of our projects uses some mock objects for running some JUnit
> > tests. These objects were put in the appropriate packages under the
> > src/test folder in one of the sub-modules. Now we want to use these
> > mock objects in the JUnit tests of one of the other sub-modules.
> > However, when Maven tries to compile the test classes in the second
> > sub-module it says it can't find the mock objects. I assume this is
> > because you can't reference classes in the src/test section of another
> > project. Is this true?
>
> Correct.  Artifacts don't contain test classes and resources.
>
>
> > Is there any way to change this? Or should we
> > pull all the mock objects into a separate sub-module and have both the
> > other modules reference them there?
>
> That is the recommended approach - create a "Test Framework" project and put the
> common test classes in the src/main area, not the src/test (if your dir
> structure matches the Maven defaults).
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Test dependencies

Posted by Jeff Jensen <je...@upstairstechnology.com>.
Quoting Aaron Freeman <aa...@gmail.com>:

> One of our projects uses some mock objects for running some JUnit
> tests. These objects were put in the appropriate packages under the
> src/test folder in one of the sub-modules. Now we want to use these
> mock objects in the JUnit tests of one of the other sub-modules.
> However, when Maven tries to compile the test classes in the second
> sub-module it says it can't find the mock objects. I assume this is
> because you can't reference classes in the src/test section of another
> project. Is this true?

Correct.  Artifacts don't contain test classes and resources.


> Is there any way to change this? Or should we
> pull all the mock objects into a separate sub-module and have both the
> other modules reference them there?

That is the recommended approach - create a "Test Framework" project and put the
common test classes in the src/main area, not the src/test (if your dir
structure matches the Maven defaults).


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org