ITeye博客

maven2中使用junit4

dcriori · 2010-01-11 14:35 · Maven · 编程语言 · Markdown

Maven2默认的Junit是3.8.1,因为以前用的一直是Junit4,感觉很不习惯。在google中搜一下,还真找到了Maven的Junit4的插件。http://wiki.unto.net/Maven_JUnit4_plugin,不敢独享。
只要在POM.XML中加入下面的代码。运行mvn test 就可以了。

<dependencies>
   <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.0</version>
     <scope>test</scope>
   </dependency>
 </dependencies>
 
 <build>
   <plugins>
     <plugin>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
         <source>1.5</source>
         <target>1.5</target>
       </configuration>
     </plugin>
     <plugin>
       <groupId>net.unto.maven.plugins</groupId>
       <artifactId>maven-junit4-plugin</artifactId>
       <version>1.0-SNAPSHOT</version>
       <executions>
         <execution>
           <phase>test</phase>
           <goals>
             <goal>test</goal>
           </goals>
         </execution>
       </executions>
     </plugin>
   </plugins>
 </build>
 
 <pluginRepositories>
   <pluginRepository>
     <id>unto.net</id>
     <url>http://repository.unto.net/maven/</url>
     <releases>
       <updatePolicy>daily</updatePolicy>
       <checksumPolicy>warn</checksumPolicy>
     </releases>
     <snapshots>
       <updatePolicy>daily</updatePolicy>
       <checksumPolicy>warn</checksumPolicy>
     </snapshots>
   </pluginRepository>
 </pluginRepositories>

转载:http://blog.csdn.net/wfnlibo/archive/2006/11/26/1414754.aspx

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。