You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Allan Ramirez <ar...@exist.com> on 2005/06/30 04:54:44 UTC

[M2a3] unit-test not working

Hi everyone,

I have overrided the source and test directories in my pom.xml

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.exist.aqr</groupId>
  <artifactId>junit-sample</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven 2 JUnit Sample</name>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
        <sourceDirectory>src/java</sourceDirectory>
        <testSourceDirectory>src/test</testSourceDirectory>
  </build>
</project>


however, when I tried to run "m2 install", Although it builds 
successfully but it also says that there are no test to run.
Am I missing something in my pom.xml?
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no test to run.

Results :
[surefire] Tests run: 0, Failures: 0, Errors: 0


-allan

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


Re: [M2a3] unit-test not working

Posted by Allan Ramirez <ar...@exist.com>.
Johnny Ruiz wrote:

> Allan Ramirez wrote:
>
>> Allan Ramirez wrote:
>>
>>> Hi everyone,
>>>
>>> I have overrided the source and test directories in my pom.xml
>>>
>>> <project>
>>>  <modelVersion>4.0.0</modelVersion>
>>>  <groupId>com.exist.aqr</groupId>
>>>  <artifactId>junit-sample</artifactId>
>>>  <packaging>jar</packaging>
>>>  <version>1.0-SNAPSHOT</version>
>>>  <name>Maven 2 JUnit Sample</name>
>>>
>>>  <dependencies>
>>>    <dependency>
>>>      <groupId>junit</groupId>
>>>      <artifactId>junit</artifactId>
>>>      <version>3.8.1</version>
>>>      <scope>test</scope>
>>>    </dependency>
>>>  </dependencies>
>>>  <build>
>>>        <sourceDirectory>src/java</sourceDirectory>
>>>        <testSourceDirectory>src/test</testSourceDirectory>
>>>  </build>
>>> </project>
>>>
>>>
>>> however, when I tried to run "m2 install", Although it builds 
>>> successfully but it also says that there are no test to run.
>>> Am I missing something in my pom.xml?
>>> -------------------------------------------------------
>>> T E S T S
>>> -------------------------------------------------------
>>> There are no test to run.
>>>
>>> Results :
>>> [surefire] Tests run: 0, Failures: 0, Errors: 0
>>>
>>>
>>> -allan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>> Hi Again.. I got it worked.. I just have to rename my test files to  
>> <name>Test.java
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
> When converting a project from M1 build à M2  build,  one might 
> encounter a problem with the Unit Testing when the test files are not 
> following this naming convention  à "*Test.java ". This is because , 
> by default M2 will only trigger unit test files with naming pattern 
> such as *Test.java .
> To be able to include files with different naming convention, 
> maven-surefire-plugin must be configured in pom.xml.  Here's a snippet 
> of the plugin that must be inserted under the build tag of POM.xml:
>
> <plugins>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>            <goals>
>            <goal>                           <id>test</id>
>               <configuration>
>                  <includes>
>                     <include 
> implementation="java.lang.String">**/*Test.java</include>
>                  </includes>
>              </configuration>
>             </goal>
>            </goals>
>      </plugin>
>    </plugins>
>
> Take note that you must put the file name pattern inside <include> 
> </include> tag.  And also the implementation="java.lang.String" part 
> is very important (thanks to evenisse) .  You might encounter error 
> when you omit this part.
> I might be mistaken, please correct me if ever.  :)
>
>

Thanks I havent thought about that.. :D Thanks again for your advice :D

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


Re: [M2a3] unit-test not working

Posted by Johnny Ruiz <jr...@exist.com>.
Allan Ramirez wrote:

> Allan Ramirez wrote:
>
>> Hi everyone,
>>
>> I have overrided the source and test directories in my pom.xml
>>
>> <project>
>>  <modelVersion>4.0.0</modelVersion>
>>  <groupId>com.exist.aqr</groupId>
>>  <artifactId>junit-sample</artifactId>
>>  <packaging>jar</packaging>
>>  <version>1.0-SNAPSHOT</version>
>>  <name>Maven 2 JUnit Sample</name>
>>
>>  <dependencies>
>>    <dependency>
>>      <groupId>junit</groupId>
>>      <artifactId>junit</artifactId>
>>      <version>3.8.1</version>
>>      <scope>test</scope>
>>    </dependency>
>>  </dependencies>
>>  <build>
>>        <sourceDirectory>src/java</sourceDirectory>
>>        <testSourceDirectory>src/test</testSourceDirectory>
>>  </build>
>> </project>
>>
>>
>> however, when I tried to run "m2 install", Although it builds 
>> successfully but it also says that there are no test to run.
>> Am I missing something in my pom.xml?
>> -------------------------------------------------------
>> T E S T S
>> -------------------------------------------------------
>> There are no test to run.
>>
>> Results :
>> [surefire] Tests run: 0, Failures: 0, Errors: 0
>>
>>
>> -allan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>
> Hi Again.. I got it worked.. I just have to rename my test files to  
> <name>Test.java
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
When converting a project from M1 build à M2  build,  one might 
encounter a problem with the Unit Testing when the test files are not 
following this naming convention  à "*Test.java ". This is because , by 
default M2 will only trigger unit test files with naming pattern such as 
*Test.java . 

 To be able to include files with different naming convention, 
maven-surefire-plugin must be configured in pom.xml.  Here's a snippet 
of the plugin that must be inserted under the build tag of POM.xml:

 <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
            <goals>
            <goal>             
               <id>test</id>
               <configuration>
                  <includes>
                     <include 
implementation="java.lang.String">**/*Test.java</include>
                  </includes>
              </configuration>
             </goal>
            </goals>
      </plugin>
    </plugins>

 Take note that you must put the file name pattern inside <include> 
</include> tag.  And also the implementation="java.lang.String" part is 
very important (thanks to evenisse) .  You might encounter error when 
you omit this part. 

I might be mistaken, please correct me if ever.  :) 



Re: [M2a3] unit-test not working

Posted by Allan Ramirez <ar...@exist.com>.
Allan Ramirez wrote:

> Hi everyone,
>
> I have overrided the source and test directories in my pom.xml
>
> <project>
>  <modelVersion>4.0.0</modelVersion>
>  <groupId>com.exist.aqr</groupId>
>  <artifactId>junit-sample</artifactId>
>  <packaging>jar</packaging>
>  <version>1.0-SNAPSHOT</version>
>  <name>Maven 2 JUnit Sample</name>
>
>  <dependencies>
>    <dependency>
>      <groupId>junit</groupId>
>      <artifactId>junit</artifactId>
>      <version>3.8.1</version>
>      <scope>test</scope>
>    </dependency>
>  </dependencies>
>  <build>
>        <sourceDirectory>src/java</sourceDirectory>
>        <testSourceDirectory>src/test</testSourceDirectory>
>  </build>
> </project>
>
>
> however, when I tried to run "m2 install", Although it builds 
> successfully but it also says that there are no test to run.
> Am I missing something in my pom.xml?
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> There are no test to run.
>
> Results :
> [surefire] Tests run: 0, Failures: 0, Errors: 0
>
>
> -allan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

Hi Again.. I got it worked.. I just have to rename my test files to  
<name>Test.java


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