maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johnny Ruiz <jr...@exist.com>
Subject Re: [M2a3] unit-test not working
Date Fri, 01 Jul 2005 10:01:38 GMT
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.  :) 



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message