You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Enrique Gaona <eg...@us.ibm.com> on 2007/04/18 16:54:38 UTC

JUnit tests are being skipped by Maven

Hi,
I'm trying to run a JUnit test in Maven, but for some reason, the tests are
being skipped.  In my pom.xml file, I have the junit dependency and added
the maven-surefire-plugin in the hopes my JUnit test gets invoked.

<dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
 </dependency>

<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
                      <includes>
                                 <include>AssetManagerTest.java</include>
                       </includes>
           </configuration>
 </plugin>

Is there anything I need to do different?   The Junit test is 10
sub-directories deep from the pom.xml, but I don't think this is an issue.
I've also included a screenshot of the output from the mvn test command.
Thanks in advance.

Screenshot from mvn test command:
egaona@zeagle:~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd>
 mvn test
[INFO] Scanning for projects...
[INFO]
----------------------------------------------------------------------------
[INFO] Building catalog.repository.cmd
[INFO]    task-segment: [test]
[INFO]
----------------------------------------------------------------------------
[INFO] [buildnumber:create {execution: default}]
[INFO] Build Number: 20070418-0955
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[WARNING]
        Artifact junit:junit:jar:3.8.1:test retains local scope 'test'
overriding broader scope 'compile'
        given by a dependency. If this is not intended, modify or remove
the local scope.

[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
[INFO] Final Memory: 15M/36M
[INFO]
------------------------------------------------------------------------


Enrique

Filtering with Maven 2.0.5

Posted by "Kesara, Soma Sekhara Reddy" <Sk...@Templeton.com>.
Hello all

Is it possible to filter some of the resources / classes using maven?

I have a scenario where I have to create two different jars one is ejb
jar and other is helper classes. 

Can some one suggest how to do this with out using assembly?

Thanks and Regards
SomaSekharaReddy.K
Notice:  All email and instant messages (including attachments) sent to
or from Franklin Templeton Investments (FTI) personnel may be retained,
monitored and/or reviewed by FTI and its agents, or authorized
law enforcement personnel, without further notice or consent.

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


Re: JUnit tests are being skipped by Maven

Posted by Enrique Gaona <eg...@us.ibm.com>.
Wayne,
Thanks for the solutions you've provided.   I went with the 2nd choice and
got my JUnit tests to build and execute.   Thanks again, very much
appreciate the help.

Enrique



"Wayne Fay" <wa...@gmail.com> wrote on 04/18/2007 11:22:41 AM:

> I figured as much. Here's your problem...
>
> Your junit artifact is brought in with scope test.
>
> Your test is currently situated in src/main/java which is "main java
> code" directory. So when maven-compiler is trying to compile your
> code, the junit dependency is not available.
>
> You have two choices:
> 1. Change junit scope to "compile". This will get you past your
> current problems but its really not the proper solution.
> 2. Move your test(s) to src/test/java. This is the "proper" solution.
>
> There's actually another choice in there where you would use
> resources, testSourceDirectory, includes and excludes to make things
> work but its complicated and I'm not going to recommend that approach.
>
> Wayne
>
> On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
> >
> > Arik,
> > Thanks for the tip.  I got a bit further and it actually tries to build
> > AssetManagerTest.java files, but its failing saying it can't find
> > junit.framework.  junit is located in
~/.m2/repository/junit/junit/3.8.1
> > directory.   I have the import junit.framework.* in my code, so not
sure
> > why it can't find the package.  Any ideas?
> >
> > /home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.
> catalog/catalog.repository.
>
cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.

> java:[22,0]
> >  package junit.framework does not exist
> >
> > /home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.
> catalog/catalog.repository.
>
cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.

> java:[30,38]
> >  cannot resolve symbol
> > symbol  : class TestCase
> > location: class
> > com.ibm.csdp.bss.catalog.repository.client.main.AssetManagerTest
> >
> > Wayne,
> > The file is called AssetManagerTest.java. The pom.xml is located in
> > ~/catalog.repository.cmd while the AssetManagerTest.java is in
> > catalog.repository.
> cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/
> >  directory.
> >
> > Thanks.
> >
> > Enrique
> >
> >
> >
> > "Arik Kfir" <ar...@gmail.com> wrote on 04/18/2007 09:59:50 AM:
> >
> > > try:
> > >
> > > <include>**/AssetManagerTest.java</include>
> > >
> > > On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
> > > >
> > > >
> > > > Hi,
> > > > I'm trying to run a JUnit test in Maven, but for some reason, the
tests
> > > > are
> > > > being skipped.  In my pom.xml file, I have the junit dependency and
> > added
> > > > the maven-surefire-plugin in the hopes my JUnit test gets invoked.
> > > >
> > > > <dependency>
> > > >         <groupId>junit</groupId>
> > > >         <artifactId>junit</artifactId>
> > > >         <version>3.8.1</version>
> > > >         <scope>test</scope>
> > > > </dependency>
> > > >
> > > > <plugin>
> > > >           <groupId>org.apache.maven.plugins</groupId>
> > > >           <artifactId>maven-surefire-plugin</artifactId>
> > > >           <configuration>
> > > >                       <includes>
> > > >
> > <include>AssetManagerTest.java</include>
> > > >                        </includes>
> > > >            </configuration>
> > > > </plugin>
> > > >
> > > > Is there anything I need to do different?   The Junit test is 10
> > > > sub-directories deep from the pom.xml, but I don't think this is an
> > issue.
> > > > I've also included a screenshot of the output from the mvn test
> > command.
> > > > Thanks in advance.
> > > >
> > > > Screenshot from mvn test command:
> > > > egaona@zeagle
> > > > :~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.
> > > catalog/catalog.repository.cmd>
> > > > mvn test
> > > > [INFO] Scanning for projects...
> > > > [INFO]
> > > >
> > > >
> >
----------------------------------------------------------------------------

> >
> > > > [INFO] Building catalog.repository.cmd
> > > > [INFO]    task-segment: [test]
> > > > [INFO]
> > > >
> > > >
> >
----------------------------------------------------------------------------

> >
> > > > [INFO] [buildnumber:create {execution: default}]
> > > > [INFO] Build Number: 20070418-0955
> > > > [INFO] [resources:resources]
> > > > [INFO] Using default encoding to copy filtered resources.
> > > > [WARNING]
> > > >         Artifact junit:junit:jar:3.8.1:test retains local scope
'test'
> > > > overriding broader scope 'compile'
> > > >         given by a dependency. If this is not intended, modify or
> > remove
> > > > the local scope.
> > > >
> > > > [INFO] [compiler:compile]
> > > > [INFO] Nothing to compile - all classes are up to date
> > > > [INFO] [resources:testResources]
> > > > [INFO] Using default encoding to copy filtered resources.
> > > > [INFO] [compiler:testCompile]
> > > > [INFO] Not compiling test sources
> > > > [INFO] [surefire:test]
> > > > [INFO] Tests are skipped.
> > > > [INFO]
> > > >
> >
------------------------------------------------------------------------
> > > > [INFO] BUILD SUCCESSFUL
> > > > [INFO]
> > > >
> >
------------------------------------------------------------------------
> > > > [INFO] Total time: 12 seconds
> > > > [INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
> > > > [INFO] Final Memory: 15M/36M
> > > > [INFO]
> > > >
> >
------------------------------------------------------------------------
> > > >
> > > >
> > > > Enrique
> > > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

Re: JUnit tests are being skipped by Maven

Posted by Wayne Fay <wa...@gmail.com>.
I figured as much. Here's your problem...

Your junit artifact is brought in with scope test.

Your test is currently situated in src/main/java which is "main java
code" directory. So when maven-compiler is trying to compile your
code, the junit dependency is not available.

You have two choices:
1. Change junit scope to "compile". This will get you past your
current problems but its really not the proper solution.
2. Move your test(s) to src/test/java. This is the "proper" solution.

There's actually another choice in there where you would use
resources, testSourceDirectory, includes and excludes to make things
work but its complicated and I'm not going to recommend that approach.

Wayne

On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
>
> Arik,
> Thanks for the tip.  I got a bit further and it actually tries to build
> AssetManagerTest.java files, but its failing saying it can't find
> junit.framework.  junit is located in ~/.m2/repository/junit/junit/3.8.1
> directory.   I have the import junit.framework.* in my code, so not sure
> why it can't find the package.  Any ideas?
>
> /home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.java:[22,0]
>  package junit.framework does not exist
>
> /home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.java:[30,38]
>  cannot resolve symbol
> symbol  : class TestCase
> location: class
> com.ibm.csdp.bss.catalog.repository.client.main.AssetManagerTest
>
> Wayne,
> The file is called AssetManagerTest.java. The pom.xml is located in
> ~/catalog.repository.cmd while the AssetManagerTest.java is in
> catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/
>  directory.
>
> Thanks.
>
> Enrique
>
>
>
> "Arik Kfir" <ar...@gmail.com> wrote on 04/18/2007 09:59:50 AM:
>
> > try:
> >
> > <include>**/AssetManagerTest.java</include>
> >
> > On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
> > >
> > >
> > > Hi,
> > > I'm trying to run a JUnit test in Maven, but for some reason, the tests
> > > are
> > > being skipped.  In my pom.xml file, I have the junit dependency and
> added
> > > the maven-surefire-plugin in the hopes my JUnit test gets invoked.
> > >
> > > <dependency>
> > >         <groupId>junit</groupId>
> > >         <artifactId>junit</artifactId>
> > >         <version>3.8.1</version>
> > >         <scope>test</scope>
> > > </dependency>
> > >
> > > <plugin>
> > >           <groupId>org.apache.maven.plugins</groupId>
> > >           <artifactId>maven-surefire-plugin</artifactId>
> > >           <configuration>
> > >                       <includes>
> > >
> <include>AssetManagerTest.java</include>
> > >                        </includes>
> > >            </configuration>
> > > </plugin>
> > >
> > > Is there anything I need to do different?   The Junit test is 10
> > > sub-directories deep from the pom.xml, but I don't think this is an
> issue.
> > > I've also included a screenshot of the output from the mvn test
> command.
> > > Thanks in advance.
> > >
> > > Screenshot from mvn test command:
> > > egaona@zeagle
> > > :~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.
> > catalog/catalog.repository.cmd>
> > > mvn test
> > > [INFO] Scanning for projects...
> > > [INFO]
> > >
> > >
> ----------------------------------------------------------------------------
>
> > > [INFO] Building catalog.repository.cmd
> > > [INFO]    task-segment: [test]
> > > [INFO]
> > >
> > >
> ----------------------------------------------------------------------------
>
> > > [INFO] [buildnumber:create {execution: default}]
> > > [INFO] Build Number: 20070418-0955
> > > [INFO] [resources:resources]
> > > [INFO] Using default encoding to copy filtered resources.
> > > [WARNING]
> > >         Artifact junit:junit:jar:3.8.1:test retains local scope 'test'
> > > overriding broader scope 'compile'
> > >         given by a dependency. If this is not intended, modify or
> remove
> > > the local scope.
> > >
> > > [INFO] [compiler:compile]
> > > [INFO] Nothing to compile - all classes are up to date
> > > [INFO] [resources:testResources]
> > > [INFO] Using default encoding to copy filtered resources.
> > > [INFO] [compiler:testCompile]
> > > [INFO] Not compiling test sources
> > > [INFO] [surefire:test]
> > > [INFO] Tests are skipped.
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] BUILD SUCCESSFUL
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Total time: 12 seconds
> > > [INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
> > > [INFO] Final Memory: 15M/36M
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > >
> > >
> > > Enrique
> > >

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


Re: JUnit tests are being skipped by Maven

Posted by Enrique Gaona <eg...@us.ibm.com>.
Arik,
Thanks for the tip.  I got a bit further and it actually tries to build
AssetManagerTest.java files, but its failing saying it can't find
junit.framework.  junit is located in ~/.m2/repository/junit/junit/3.8.1
directory.   I have the import junit.framework.* in my code, so not sure
why it can't find the package.  Any ideas?

/home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.java:[22,0]
 package junit.framework does not exist

/home/egaona/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/AssetManagerTest.java:[30,38]
 cannot resolve symbol
symbol  : class TestCase
location: class
com.ibm.csdp.bss.catalog.repository.client.main.AssetManagerTest

Wayne,
The file is called AssetManagerTest.java. The pom.xml is located in
~/catalog.repository.cmd while the AssetManagerTest.java is in
catalog.repository.cmd/src/main/java/com/ibm/csdp/bss/catalog/repository/client/main/
 directory.

Thanks.

Enrique



"Arik Kfir" <ar...@gmail.com> wrote on 04/18/2007 09:59:50 AM:

> try:
>
> <include>**/AssetManagerTest.java</include>
>
> On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
> >
> >
> > Hi,
> > I'm trying to run a JUnit test in Maven, but for some reason, the tests
> > are
> > being skipped.  In my pom.xml file, I have the junit dependency and
added
> > the maven-surefire-plugin in the hopes my JUnit test gets invoked.
> >
> > <dependency>
> >         <groupId>junit</groupId>
> >         <artifactId>junit</artifactId>
> >         <version>3.8.1</version>
> >         <scope>test</scope>
> > </dependency>
> >
> > <plugin>
> >           <groupId>org.apache.maven.plugins</groupId>
> >           <artifactId>maven-surefire-plugin</artifactId>
> >           <configuration>
> >                       <includes>
> >
<include>AssetManagerTest.java</include>
> >                        </includes>
> >            </configuration>
> > </plugin>
> >
> > Is there anything I need to do different?   The Junit test is 10
> > sub-directories deep from the pom.xml, but I don't think this is an
issue.
> > I've also included a screenshot of the output from the mvn test
command.
> > Thanks in advance.
> >
> > Screenshot from mvn test command:
> > egaona@zeagle
> > :~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.
> catalog/catalog.repository.cmd>
> > mvn test
> > [INFO] Scanning for projects...
> > [INFO]
> >
> >
----------------------------------------------------------------------------

> > [INFO] Building catalog.repository.cmd
> > [INFO]    task-segment: [test]
> > [INFO]
> >
> >
----------------------------------------------------------------------------

> > [INFO] [buildnumber:create {execution: default}]
> > [INFO] Build Number: 20070418-0955
> > [INFO] [resources:resources]
> > [INFO] Using default encoding to copy filtered resources.
> > [WARNING]
> >         Artifact junit:junit:jar:3.8.1:test retains local scope 'test'
> > overriding broader scope 'compile'
> >         given by a dependency. If this is not intended, modify or
remove
> > the local scope.
> >
> > [INFO] [compiler:compile]
> > [INFO] Nothing to compile - all classes are up to date
> > [INFO] [resources:testResources]
> > [INFO] Using default encoding to copy filtered resources.
> > [INFO] [compiler:testCompile]
> > [INFO] Not compiling test sources
> > [INFO] [surefire:test]
> > [INFO] Tests are skipped.
> > [INFO]
> >
------------------------------------------------------------------------
> > [INFO] BUILD SUCCESSFUL
> > [INFO]
> >
------------------------------------------------------------------------
> > [INFO] Total time: 12 seconds
> > [INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
> > [INFO] Final Memory: 15M/36M
> > [INFO]
> >
------------------------------------------------------------------------
> >
> >
> > Enrique
> >

Re: JUnit tests are being skipped by Maven

Posted by Arik Kfir <ar...@gmail.com>.
try:

<include>**/AssetManagerTest.java</include>

On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
>
>
> Hi,
> I'm trying to run a JUnit test in Maven, but for some reason, the tests
> are
> being skipped.  In my pom.xml file, I have the junit dependency and added
> the maven-surefire-plugin in the hopes my JUnit test gets invoked.
>
> <dependency>
>         <groupId>junit</groupId>
>         <artifactId>junit</artifactId>
>         <version>3.8.1</version>
>         <scope>test</scope>
> </dependency>
>
> <plugin>
>           <groupId>org.apache.maven.plugins</groupId>
>           <artifactId>maven-surefire-plugin</artifactId>
>           <configuration>
>                       <includes>
>                                  <include>AssetManagerTest.java</include>
>                        </includes>
>            </configuration>
> </plugin>
>
> Is there anything I need to do different?   The Junit test is 10
> sub-directories deep from the pom.xml, but I don't think this is an issue.
> I've also included a screenshot of the output from the mvn test command.
> Thanks in advance.
>
> Screenshot from mvn test command:
> egaona@zeagle
> :~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd>
> mvn test
> [INFO] Scanning for projects...
> [INFO]
>
> ----------------------------------------------------------------------------
> [INFO] Building catalog.repository.cmd
> [INFO]    task-segment: [test]
> [INFO]
>
> ----------------------------------------------------------------------------
> [INFO] [buildnumber:create {execution: default}]
> [INFO] Build Number: 20070418-0955
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [WARNING]
>         Artifact junit:junit:jar:3.8.1:test retains local scope 'test'
> overriding broader scope 'compile'
>         given by a dependency. If this is not intended, modify or remove
> the local scope.
>
> [INFO] [compiler:compile]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [resources:testResources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:testCompile]
> [INFO] Not compiling test sources
> [INFO] [surefire:test]
> [INFO] Tests are skipped.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 12 seconds
> [INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
> [INFO] Final Memory: 15M/36M
> [INFO]
> ------------------------------------------------------------------------
>
>
> Enrique
>

Re: JUnit tests are being skipped by Maven

Posted by Wayne Fay <wa...@gmail.com>.
What is the file named? And where is it located with respect to your
pom.xml (the complete relative path)?

Wayne

On 4/18/07, Enrique Gaona <eg...@us.ibm.com> wrote:
>
> Hi,
> I'm trying to run a JUnit test in Maven, but for some reason, the tests are
> being skipped.  In my pom.xml file, I have the junit dependency and added
> the maven-surefire-plugin in the hopes my JUnit test gets invoked.
>
> <dependency>
>         <groupId>junit</groupId>
>         <artifactId>junit</artifactId>
>         <version>3.8.1</version>
>         <scope>test</scope>
>  </dependency>
>
> <plugin>
>           <groupId>org.apache.maven.plugins</groupId>
>           <artifactId>maven-surefire-plugin</artifactId>
>           <configuration>
>                       <includes>
>                                  <include>AssetManagerTest.java</include>
>                        </includes>
>            </configuration>
>  </plugin>
>
> Is there anything I need to do different?   The Junit test is 10
> sub-directories deep from the pom.xml, but I don't think this is an issue.
> I've also included a screenshot of the output from the mvn test command.
> Thanks in advance.
>
> Screenshot from mvn test command:
> egaona@zeagle:~/projects/csdp_build/sources/csdp/com.ibm.csdp.bss.catalog/catalog.repository.cmd>
>  mvn test
> [INFO] Scanning for projects...
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] Building catalog.repository.cmd
> [INFO]    task-segment: [test]
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] [buildnumber:create {execution: default}]
> [INFO] Build Number: 20070418-0955
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [WARNING]
>         Artifact junit:junit:jar:3.8.1:test retains local scope 'test'
> overriding broader scope 'compile'
>         given by a dependency. If this is not intended, modify or remove
> the local scope.
>
> [INFO] [compiler:compile]
> [INFO] Nothing to compile - all classes are up to date
> [INFO] [resources:testResources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:testCompile]
> [INFO] Not compiling test sources
> [INFO] [surefire:test]
> [INFO] Tests are skipped.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 12 seconds
> [INFO] Finished at: Wed Apr 18 09:55:18 CDT 2007
> [INFO] Final Memory: 15M/36M
> [INFO]
> ------------------------------------------------------------------------
>
>
> Enrique
>

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