传统项目目录结构下maven+junit+junitReport

  1. <build>  
  2.         <defaultGoal>compile</defaultGoal>  
  3.         <sourceDirectory>${basedir}/src</sourceDirectory>  
  4.         <outputDirectory>${basedir}/WebRoot/WEB-INF/classes</outputDirectory>  
  5.         <resources>  
  6.             <resource>  
  7.                 <directory>${basedir}/src</directory>  
  8.                 <excludes>  
  9.                     <exclude>**/*.java</exclude>  
  10.                 </excludes>  
  11.             </resource>  
  12.         </resources>  
  13.         <plugins>  
  14.             <plugin>  
  15.                 <artifactId>maven-war-plugin</artifactId>  
  16.                 <configuration>  
  17.                     <webappDirectory>${basedir}/WebRoot</webappDirectory>  
  18.                     <warSourceDirectory>${basedir}/WebRoot</warSourceDirectory>  
  19.                 </configuration>  
  20.             </plugin>  
  21.             <plugin>  
  22.                 <artifactId>maven-compiler-plugin</artifactId>  
  23.                 <version>2.1</version>   
  24.                 <configuration>  
  25.                     <source>1.6</source>  
  26.                     <target>1.6</target>  
  27.                 </configuration>  
  28.             </plugin>  
  29.               
  30.             <plugin>    
  31.               <groupId>org.apache.maven.plugins</groupId>    
  32.               <artifactId>maven-surefire-plugin</artifactId>    
  33.               <version>2.5</version>    
  34.               <configuration>  
  35.                 <!-- 指定测试文件路径-->  
  36.                 <testSourceDirectory>${basedir}/src</testSourceDirectory>  
  37.                 <testClassesDirectory>${basedir}/WebRoot/WEB-INF/classes</testClassesDirectory>    
  38.                 <skip>false</skip>  
  39.                 <testFailureIgnore>true</testFailureIgnore>  
  40.                 <!--   
  41.                 <properties>  
  42.                               <property>  
  43.                                 <name>usedefaultlisteners</name>  
  44.                                 <value>false</value>  
  45.                               </property>  
  46.                               <property>  
  47.                                 <name>listener</name>  
  48.                                 <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>  
  49.                               </property>  
  50.                            </properties>  
  51.                            -->  
  52.                 
  53.               </configuration>    
  54.             </plugin>  
  55.             <plugin>  
  56.                 <!-- Extended Maven antrun plugin -->  
  57.                 <!-- https://maven-antrun-extended-plugin.dev.java.net/ -->  
  58.                 <!-- 将junit生成的xml文件转成html -->  
  59.                 <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>  
  60.                 <artifactId>maven-antrun-extended-plugin</artifactId>  
  61.                 <executions>  
  62.                     <execution>  
  63.                         <id>test-reports</id>  
  64.                         <phase>test</phase>  
  65.                         <configuration>  
  66.                             <tasks>  
  67.                                 <junitreport todir="${basedir}/target/surefire-reports">  
  68.                                     <fileset dir="${basedir}/target/surefire-reports">  
  69.                                         <include name="**/*.xml" />  
  70.                                     </fileset>  
  71.                                     <report format="noframes" todir="${basedir}/target/surefire-reports" />  
  72.                                 </junitreport>  
  73.                             </tasks>  
  74.                         </configuration>  
  75.                         <goals>  
  76.                             <goal>run</goal>  
  77.                         </goals>  
  78.                     </execution>  
  79.                 </executions>  
  80.                 <dependencies>  
  81.                     <dependency>  
  82.                         <groupId>org.apache.ant</groupId>  
  83.                         <artifactId>ant-junit</artifactId>  
  84.                         <version>1.8.0</version>  
  85.                     </dependency>  
  86.                     <dependency>  
  87.                         <groupId>org.apache.ant</groupId>  
  88.                         <artifactId>ant-trax</artifactId>  
  89.                         <version>1.8.0</version>  
  90.                     </dependency>  
  91.                 </dependencies>  
  92.             </plugin>  
  93.         </plugins>  
  94.     </build>  
  95.       
  96.       
  97.     <!-- Junit Report plugin -->  
  98.     <reporting>  
  99.         <plugins>  
  100.             <plugin>  
  101.                 <groupId>org.apache.maven.plugins</groupId>  
  102.                 <artifactId>maven-surefire-report-plugin</artifactId>  
  103.                 <version>2.16</version>  
  104.                 <configuration>  
  105.                     <showSuccess>false</showSuccess>  
  106.                     <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>  
  107.                 </configuration>  
  108.             </plugin>  
  109.             <plugin>  
  110.                 <groupId>org.apache.maven.plugins</groupId>  
  111.                 <artifactId>maven-site-plugin</artifactId>  
  112.                 <version>3.3</version>  
  113.                 <configuration>  
  114.                     <outputDirectory>${basedir}/target/surefire-reports</outputDirectory>  
  115.                 </configuration>  
  116.             </plugin>  
  117.         </plugins>  
  118.     </reporting>  
posted @ 2018-02-11 14:23  小学生II  阅读(248)  评论(0编辑  收藏  举报