亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > TestNG
使用TestNG的新特性管理實際項目中的大量單元測試
作者:網絡轉載 發布時間:[ 2013/3/15 13:59:56 ] 推薦標簽:

TestNG 的示例代碼

TestNG 提供了從命令行運行測試用例的方法。下面將首先從命令行運行測試用例。假設有如下的測試用例組:

列表 1. TestNG 示例代碼

    
 package example1;

 import org.testng.annotations.*;

 public class SimpleTest {

  @Configuration(beforeTestClass = true)
  public void setUp() {
    // code that will be invoked when this test is instantiated
  }

  @Test(groups = { "HelloWorld" })
  public void helloWorldTest() {
    System.out.println("Hello World");
    throw new Error();
  }

  @Test(threadPoolSize = 10, invocationCount = 5, 
  timeOut = 1000, groups = { "multiple" })
  public void multiThreadTest() {
     System.out.println("MultiThread test");
  }

  @Test(groups = { "HelloNature" })
  public void helloNatureTest() {
     System.out.println("Hello Nature");
     throw new Error();
  }
 }

    


運行 TestNG 的 Ant 腳本

為了運行這組測試用例,構建了如下的 Ant 運行腳本:

列表 2. 運行測試用例組的 Ant 腳本 build.xml 文件

    
 <project default="test">

  <path id="cp">
    <pathelement location=
    "c:/spark/eclipse/plugins/org.testng.eclipse_4.7.0.0/lib/testng-jdk15.jar"/>
    <pathelement location="c:"/>
  </path>
 
  <taskdef name="testng" classpathref="cp"
           classname="org.testng.TestNGAntTask" />

 <target name="test">
    <testng classpathref="cp" groups="HelloWorld, HelloNature">
      <classfileset dir="./" includes="example1/*.class"/>
    </testng>
  </target>
 
 </project>


運行之后的結果如下:

圖 1. 命令行運行 TestNG 的結果

運行完成之后,會在運行目錄下生成一個 test-output 目錄。如圖 2 所示:

圖 2. 生成的 test-output 目錄

該目錄中包含有 html 形式的運行結果的報告,通過命令 start test-outputindex.html 可以查看生成的測試報告。

上一頁123下一頁
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 韩国 欧美 日产 国产精品 | 久久精品94精品久久精品动漫 | 国产在线97色永久免费视频 | 欧美日韩成人在线视频 | 欧美大片大片播放网站 | 一级黄色在线观看 | vr欧美乱强伦xxxxx | 性a视频 | 国产欧美一区二区三区久久 | 免费污视频在线 | 色视频线观看在线播放 | 亚洲第一二三四区 | 一级一片一_级一片一 | 黄色搞鸡网站 | 成人性色生活片免费看成人性 | 成人福利视频网址 | 国产欧美精品一区二区三区四区 | 亚洲精品亚洲人成在线观看麻豆 | 关婷哪一级毛片高清免费看 | 欧美性xx18hd | 中国老妇另类xxxx | 欧美乱子伦xxxx96 | 在线观看成人 | 91久久天天躁狠狠躁夜夜 | www.九色视频 | 亚洲另类视频在线观看 | 日本午夜三级 | 久青草视频在线观看 | www.天天色| 在线国产不卡 | 天天舔天天操天天干 | 一区二区三区四区亚洲 | 欧美videos13_14 | 免费在线黄色片 | 日韩不卡视频在线 | 免费在线看污视频 | 国产精品成人免费视频99 | 成人免费v片在线观看 | 欧美午夜性春 | 午夜剧场在线播放 | 中文一区二区在线观看 |