You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jan Torben Heuer <jt...@mail2003.dnsalias.org> on 2007/10/25 18:06:05 UTC

Re: Debugging failed junit-test

Jan Torben Heuer wrote:

> I have a problem with a junit test that failes when I run "mvn test" - but
> it does not fail when I run the test by the eclipse-junit-plugin.

Ok, I have another guess:
Could it be, that dependencies to other modules are only to sources
in /src/main/java/ but not to the test-sources in /src/test/java? (In other
words: /target/classes and /target/test-classes)

I can access a class in another module, but I cannot access a test-class in
another test-module! (It is a mock-class, i wrote)

How can I fix it?

Jan





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


Re: Debugging failed junit-test

Posted by Wayne Fay <wa...@gmail.com>.
> Creating a second artifact only for the MockObjects and request-examples is
> a bit annoying.
>
> But it seems to be the only soloution, right?

If you're using Maven2 "seriously", get used to making artifacts.

Wayne

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


Re: Debugging failed junit-test

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Tim Kettler wrote:


> They are simply not part of the artifact maven creates for module2. The
> artifact maven creates contains just the production code (classes and
> resources from 'src/main/*') as no one seriously wants to have their
> unit tests packaged alongsite the final deliverable of the project.
Ok, that make sense - although a test-compile should - in my eyes - compile
all classes to another destination.

> If you have shared testing code between two projects, just create a
> third module containig this shared code and declare it as a dependency
> in the two other modules with <scope>test</scope> or follow the guide
> Wanyne pointed you to and create a "test-jar" of the testing code in
> module2 and reference that with test scope.

Ok, if it is a library that should provide Mock Objects and
example-request-documents.
Creating a second artifact only for the MockObjects and request-examples is
a bit annoying.

But it seems to be the only soloution, right?

Jan


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


Re: Debugging failed junit-test

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

Jan Torben Heuer schrieb:
> Wayne Fay wrote:
> 
>> I'm not sure that I understand you entirely, but here goes.... If you
>> have shared test files, you will need to create a "test-jar" artifact
>> and add it as a dependency to any projects that need to use it.
>>
>> This is documented in a mini-guide:
>> http://maven.apache.org/guides/mini/guide-attached-tests.html
> 
> Why can't I reference test-classes in other modules?
> 
> I have a project with two modules. module1 dependsOn module2:
> <project>
>         <module1>
>         <module2>
> 
> I can reference m2's classes from m1, but NOT m2's testclasses. That is what
> I do not understand.

They are simply not part of the artifact maven creates for module2. The
artifact maven creates contains just the production code (classes and
resources from 'src/main/*') as no one seriously wants to have their
unit tests packaged alongsite the final deliverable of the project.

If you have shared testing code between two projects, just create a
third module containig this shared code and declare it as a dependency
in the two other modules with <scope>test</scope> or follow the guide
Wanyne pointed you to and create a "test-jar" of the testing code in
module2 and reference that with test scope.

> Jan

-Tim

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


Re: Debugging failed junit-test

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Wayne Fay wrote:

> I'm not sure that I understand you entirely, but here goes.... If you
> have shared test files, you will need to create a "test-jar" artifact
> and add it as a dependency to any projects that need to use it.
> 
> This is documented in a mini-guide:
> http://maven.apache.org/guides/mini/guide-attached-tests.html

Why can't I reference test-classes in other modules?

I have a project with two modules. module1 dependsOn module2:
<project>
        <module1>
        <module2>

I can reference m2's classes from m1, but NOT m2's testclasses. That is what
I do not understand.

Jan


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


Re: Debugging failed junit-test

Posted by Wayne Fay <wa...@gmail.com>.
I'm not sure that I understand you entirely, but here goes.... If you
have shared test files, you will need to create a "test-jar" artifact
and add it as a dependency to any projects that need to use it.

This is documented in a mini-guide:
http://maven.apache.org/guides/mini/guide-attached-tests.html

Eclipse handles some of these classpath things without telling you
about it. It is not uncommon for things to work in Eclipse but not in
Maven for this reason (nearly always classpath or classloader issues).

Wayne

On 10/25/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:
> Jan Torben Heuer wrote:
>
> > I have a problem with a junit test that failes when I run "mvn test" - but
> > it does not fail when I run the test by the eclipse-junit-plugin.
>
> Ok, I have another guess:
> Could it be, that dependencies to other modules are only to sources
> in /src/main/java/ but not to the test-sources in /src/test/java? (In other
> words: /target/classes and /target/test-classes)
>
> I can access a class in another module, but I cannot access a test-class in
> another test-module! (It is a mock-class, i wrote)
>
> How can I fix it?
>
> Jan
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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