You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by gdub <a5...@orthogony.com> on 2006/04/14 06:29:18 UTC

test cases failing in Maven but not Eclipse

I am trying to install a module that
depends on Spring and Hibernate. All
of those dependencies for the app
are in that Maven project. The trouble
is that the tests won't pass. They pass
fine in Eclipse. All the rest of the
modules for this  project pass their
tests in both Maven and Eclipse.

I can't see where the trouble is because
nothing is reported back on the failures.
The console shows INFO lines saying that
Spring is loading the configuration
files (which are all classpath resources,
BTW) but no indication of how the tests
are failing--only a message before
maven exits saying that all the tests
have failed.

I sprinkled some printlns into some test
methods to see if the test methods were
even entered--they are not (well, at
least I don't think they are, maybe
the standard output is being shunted).

The -e switch only reports the surefire
exception that there were failed tests.

I don't think module dependencies are
the issue because I am using eclipse:
eclipse to generate them for Eclipse--
i.e. they are the same in both
environments.

How do I approach finding the source of
this trouble? There doesn't appear to be
enough information to track it down.

   -dub


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


Re: test cases failing in Maven but not Eclipse

Posted by gdub <a5...@orthogony.com>.
Jakub Pawlowicz wrote:
 > Did you take a look at files in the
 > 'target/surefire-reports' directory of
 > your project?

Wayne Fay wrote:
 > Have you tried mvn -X, it reports a lot more
 > data than -e. Perhaps you'll see something
 > strange with -X?

Valerio Schiavoni wrote:
 > we spotted out that our tests were based
 > on the path of some resources only reachable
 > within eclipse



Awesome! Thanks for the help everyone.
It WAS a path problem. And the surefire-
reports dir and -X flag let me track
it down.

So, the deal was that a Spring config-
uration file wasn't found. It is a one-
bean file that defines the data source.
For the testing DB server, I made a
specialized data source config. Because
it was a one-off and only used in testing,
I just put it in with the test sources.

That was the problem. Eclipse copies
resources from all source directories
to the classpath directories. Maven
only copies the resources from the
resources directory to there.

Thanks again all,

   -dub


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


Re: test cases failing in Maven but not Eclipse

Posted by Jakub Pawlowicz <co...@jakubpawlowicz.com>.
Hi,

Did you take a look at files in the 'target/surefire-reports' directory of
your project?
The maven surefire plugin places all reports there, so you could easily check
what went wrong.

Hopes this helps you find the problem.

Regards,
Jakub

On Thu, 13 Apr 2006 21:29:18 -0700, gdub wrote
> I am trying to install a module that
> depends on Spring and Hibernate. All
> of those dependencies for the app
> are in that Maven project. The trouble
> is that the tests won't pass. They pass
> fine in Eclipse. All the rest of the
> modules for this  project pass their
> tests in both Maven and Eclipse.
> 
> I can't see where the trouble is because
> nothing is reported back on the failures.
> The console shows INFO lines saying that
> Spring is loading the configuration
> files (which are all classpath resources,
> BTW) but no indication of how the tests
> are failing--only a message before
> maven exits saying that all the tests
> have failed.
> 
> I sprinkled some printlns into some test
> methods to see if the test methods were
> even entered--they are not (well, at
> least I don't think they are, maybe
> the standard output is being shunted).
> 
> The -e switch only reports the surefire
> exception that there were failed tests.
> 
> I don't think module dependencies are
> the issue because I am using eclipse:
> eclipse to generate them for Eclipse--
> i.e. they are the same in both
> environments.
> 
> How do I approach finding the source of
> this trouble? There doesn't appear to be
> enough information to track it down.
> 
>    -dub
> 
> ---------------------------------------------------------------------
> 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: test cases failing in Maven but not Eclipse

Posted by Wayne Fay <wa...@gmail.com>.
You're not the only person reporting tests that pass in Eclipse but
not Maven. I'm not sure what's going on there, but I'm hoping someone
will eventually figure it out and let us all know what's going on
exactly. ;-)

Have you tried mvn -X, it reports a lot more data than -e. Perhaps
you'll see something strange with -X?

Also try adding this to your pom.xml to see the System.out and
System.err println()s reporting in your command line shell. But you
should really think about adding a logging system to your app and
getting rid of the System calls, its a really simple change.

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <useFile>false</useFile>
        </configuration>
      </plugin>

Wayne

On 4/13/06, gdub <a5...@orthogony.com> wrote:
> I am trying to install a module that
> depends on Spring and Hibernate. All
> of those dependencies for the app
> are in that Maven project. The trouble
> is that the tests won't pass. They pass
> fine in Eclipse. All the rest of the
> modules for this  project pass their
> tests in both Maven and Eclipse.
>
> I can't see where the trouble is because
> nothing is reported back on the failures.
> The console shows INFO lines saying that
> Spring is loading the configuration
> files (which are all classpath resources,
> BTW) but no indication of how the tests
> are failing--only a message before
> maven exits saying that all the tests
> have failed.
>
> I sprinkled some printlns into some test
> methods to see if the test methods were
> even entered--they are not (well, at
> least I don't think they are, maybe
> the standard output is being shunted).
>
> The -e switch only reports the surefire
> exception that there were failed tests.
>
> I don't think module dependencies are
> the issue because I am using eclipse:
> eclipse to generate them for Eclipse--
> i.e. they are the same in both
> environments.
>
> How do I approach finding the source of
> this trouble? There doesn't appear to be
> enough information to track it down.
>
>   -dub
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: test cases failing in Maven but not Eclipse

Posted by Eric Redmond <er...@gmail.com>.
Yeah, and on the same vein, our tests failed because of classloader issues,
because Eclipse would execute JUnit in a different hierarchy than surefire.
You may check that as well.

Eric

On 4/14/06, Valerio Schiavoni <va...@gmail.com> wrote:
>
> hi,
> when we first launched our test suites outside eclipse, directly from mvn,
> we got a lot of failures: after questioning ourselves about what was going
> on, we spotted out that our tests were based on the path of some resources
> only reachable within eclipse (maybe because they're relative..). can this
> be also your case?
>
> maybe you can post a small test which doesn't pass from maven and still
> passing within eclipse...
>
> On 4/14/06, gdub <a5...@orthogony.com> wrote:
> >
> > I am trying to install a module that
> > depends on Spring and Hibernate. All
> > of those dependencies for the app
> > are in that Maven project. The trouble
> > is that the tests won't pass. They pass
> > fine in Eclipse. All the rest of the
> > modules for this  project pass their
> > tests in both Maven and Eclipse.
> >
> > I can't see where the trouble is because
> > nothing is reported back on the failures.
> > The console shows INFO lines saying that
> > Spring is loading the configuration
> > files (which are all classpath resources,
> > BTW) but no indication of how the tests
> > are failing--only a message before
> > maven exits saying that all the tests
> > have failed.
> >
> > I sprinkled some printlns into some test
> > methods to see if the test methods were
> > even entered--they are not (well, at
> > least I don't think they are, maybe
> > the standard output is being shunted).
> >
> > The -e switch only reports the surefire
> > exception that there were failed tests.
> >
> > I don't think module dependencies are
> > the issue because I am using eclipse:
> > eclipse to generate them for Eclipse--
> > i.e. they are the same in both
> > environments.
> >
> > How do I approach finding the source of
> > this trouble? There doesn't appear to be
> > enough information to track it down.
> >
> >    -dub
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> To Iterate is Human, to Recurse, Divine
> James O. Coplien, Bell Labs
> (how good is to be human indeed)
>
>

Re: test cases failing in Maven but not Eclipse

Posted by Valerio Schiavoni <va...@gmail.com>.
hi,
when we first launched our test suites outside eclipse, directly from mvn,
we got a lot of failures: after questioning ourselves about what was going
on, we spotted out that our tests were based on the path of some resources
only reachable within eclipse (maybe because they're relative..). can this
be also your case?

maybe you can post a small test which doesn't pass from maven and still
passing within eclipse...

On 4/14/06, gdub <a5...@orthogony.com> wrote:
>
> I am trying to install a module that
> depends on Spring and Hibernate. All
> of those dependencies for the app
> are in that Maven project. The trouble
> is that the tests won't pass. They pass
> fine in Eclipse. All the rest of the
> modules for this  project pass their
> tests in both Maven and Eclipse.
>
> I can't see where the trouble is because
> nothing is reported back on the failures.
> The console shows INFO lines saying that
> Spring is loading the configuration
> files (which are all classpath resources,
> BTW) but no indication of how the tests
> are failing--only a message before
> maven exits saying that all the tests
> have failed.
>
> I sprinkled some printlns into some test
> methods to see if the test methods were
> even entered--they are not (well, at
> least I don't think they are, maybe
> the standard output is being shunted).
>
> The -e switch only reports the surefire
> exception that there were failed tests.
>
> I don't think module dependencies are
> the issue because I am using eclipse:
> eclipse to generate them for Eclipse--
> i.e. they are the same in both
> environments.
>
> How do I approach finding the source of
> this trouble? There doesn't appear to be
> enough information to track it down.
>
>    -dub
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
To Iterate is Human, to Recurse, Divine
James O. Coplien, Bell Labs
(how good is to be human indeed)

Re: test cases failing in Maven but not Eclipse

Posted by ia...@jpmchase.com.
The most likely culprite<sp?> when tests run in Eclipse but not Maven is
forking.  Eclipse runs each test in it's own forked VM, where as Maven by
default runs all tests within the same VM as mvn itself.  You can enable
the per-test forking in Maven by added the following to your pom.xml

<build>
      <plugins>
            <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <configuration>
                        <forkMode>pertest</forkMode>
                  </configuration>
            </plugin>
      </plugins>
</build>

As far as the failed tests, the output from your tests is written to
target/surefire-report by default, with an XML and .TXT file generated for
each test class.  You can force the output to be written directly to the
console by setting useFile = false, either from the command line or in the
<configuration> element of the maven-surefire-plugin.

There is also a maven-surefire-report-plugin, with generates a pretty HTML
report as part of mvn site.  Unfortunately, this plugin has two
shortcomings, IMO:

1) It re-runs all tests.  Not sure if you have to configure forkMode and
similiar settings independently of maven-surefire-plugin
2) It fails to generate a report in case of test failure, severely limiting
its utility


HTH,
Ian

It's better to be hated for who you are
than loved for who you are not

Ian D. Stewart
Appl Dev Analyst-Advisory, DCS Automation
JPMorganChase Global Technology Infrastructure
Phone: (614) 244-2564
Pager: (888) 260-0078


                                                                                                                                       
                      gdub                                                                                                             
                      <a507@orthogony.c        To:       users@maven.apache.org                                                        
                      om>                      cc:                                                                                     
                                               Subject:  test cases failing in Maven but not Eclipse                                   
                      04/14/2006 12:29                                                                                                 
                      AM                                                                                                               
                      Please respond to                                                                                                
                      "Maven Users                                                                                                     
                      List"                                                                                                            
                                                                                                                                       




I am trying to install a module that
depends on Spring and Hibernate. All
of those dependencies for the app
are in that Maven project. The trouble
is that the tests won't pass. They pass
fine in Eclipse. All the rest of the
modules for this  project pass their
tests in both Maven and Eclipse.

I can't see where the trouble is because
nothing is reported back on the failures.
The console shows INFO lines saying that
Spring is loading the configuration
files (which are all classpath resources,
BTW) but no indication of how the tests
are failing--only a message before
maven exits saying that all the tests
have failed.

I sprinkled some printlns into some test
methods to see if the test methods were
even entered--they are not (well, at
least I don't think they are, maybe
the standard output is being shunted).

The -e switch only reports the surefire
exception that there were failed tests.

I don't think module dependencies are
the issue because I am using eclipse:
eclipse to generate them for Eclipse--
i.e. they are the same in both
environments.

How do I approach finding the source of
this trouble? There doesn't appear to be
enough information to track it down.

   -dub


---------------------------------------------------------------------
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