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 17:22:21 UTC

Debugging failes junit test

Hi,

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.

My problem ist, that there are no information:

[...]
Running ogcoperations.SubscriptionTest
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.009 sec
<<< FAILURE!
Running core.LauncherTest
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.017 sec
<<< FAILURE!

Results :

Tests in error:
 
testHandleXMLSubscribeDocumentImpl(core.handler.ogcoperations.SubscriptionTest)
  testGetSubscriber(core.handler.ogcoperations.SubscriptionTest)
  testStartup(core.LauncherTest)
[...]

even running maven with "mvn -e -X test" does not create more output.
I have no idea why this test fails.

How can I get the reason for the fail (assertion error, for example)
Are there known problems with the plugin? Or other cases where the test only
fail in maven but not in the IDE?


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


Re: Debugging failed junit-test

Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
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 failes junit test

Posted by Jim Sellers <ji...@gmail.com>.
Take a look at
target/surefire-reports

In eclipse everything in src/main can "see" (on the classpath) src/test and
vis versa.

When running the tests, code in src/main cannot "see" src/test.

That might be it, but check out the output in the target/surefire-reports
for your specific issue.

HTH
Jim


On 10/25/07, Jan Torben Heuer <jt...@mail2003.dnsalias.org> wrote:
>
> Hi,
>
> 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.
>
> My problem ist, that there are no information:
>
> [...]
> Running ogcoperations.SubscriptionTest
> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.009 sec
> <<< FAILURE!
> Running core.LauncherTest
> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.017 sec
> <<< FAILURE!
>
> Results :
>
> Tests in error:
>
> testHandleXMLSubscribeDocumentImpl(
> core.handler.ogcoperations.SubscriptionTest)
>   testGetSubscriber(core.handler.ogcoperations.SubscriptionTest)
>   testStartup(core.LauncherTest)
> [...]
>
> even running maven with "mvn -e -X test" does not create more output.
> I have no idea why this test fails.
>
> How can I get the reason for the fail (assertion error, for example)
> Are there known problems with the plugin? Or other cases where the test
> only
> fail in maven but not in the IDE?
>
>
> Jan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>