Surefire maven plugging configuration for testng

The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. once you write the test classes under test directory you can use following surefire configurations in pom.xml to run you test classes while building the source.


If you want to run all test classes which name end with TestCase


<build>  
     <plugins>  
       <plugin>  
         <artifactId>maven-surefire-plugin</artifactId>  
         <version>2.12.3</version>  
         <inherited>false</inherited>  
         <configuration>  
           <argLine>-Xms512m -Xmx1024m -XX:MaxPermSize=128m</argLine>  
           <testFailureIgnore>true</testFailureIgnore>  
           <disableXmlReport>false</disableXmlReport>  
           <parallel>false</parallel>  
           <includes>  
             <include>**/*TestCase.java</include>  
           </includes>  
         </configuration>  
       </plugin>  
     </plugins>  
   </build>  

Other option is that you can create a test suite by defining test classes or test packages in a xml file called testng.xml 


<build>  
     <plugins>  
       <plugin>  
         <artifactId>maven-surefire-plugin</artifactId>  
         <version>2.12.3</version>  
         <inherited>false</inherited>  
         <configuration>  
           <argLine>-Xms512m -Xmx1024m -XX:MaxPermSize=128m</argLine>  
           <testFailureIgnore>true</testFailureIgnore>  
           <disableXmlReport>false</disableXmlReport>  
           <parallel>false</parallel>  
           <suiteXmlFiles>  
             <suiteXmlFile>src/test/resources/testng1.xml</suiteXmlFile>  
           </suiteXmlFiles>  
         </configuration>  
       </plugin>  
     </plugins>  
   </build>  

your testng.xml file should be defined as bellow. you can defined your test classes or or package to be run

<suite name="MyTestSuite" parallel="false">   
   <test name="Test1" preserve-order="true" verbose="2">   
    <classes>   
     <class name="com.test.MyTestClass1"/>  
     <class name="com.test.MyTestClass2"/>   
    </classes>   
   </test>   
  <test name="Test2" preserve-order="true" verbose="2">   
    <packages>   
     <package name="com.test.*"/>   
    </packages>   
   </test>   
  </suite>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值