亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-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
主站蜘蛛池模板: 亚洲欧美日韩国产vr在线观 | 三级免费毛片 | 九九热九九热 | 亚洲国产日韩在线观频 | 欧美成人精品一区二区三区 | 草草视频在线观看最新 | 国产一级在线播放 | 欧美成人免费tv在线播放 | 免费看一级特黄a大片 | 久操视频免费看 | 国产一国产一级毛片视频 | 欧美日韩国产免费一区二区三区 | 国产精品合集一区二区三区 | 97免费视频在线 | 欧美最猛同性video | 国产欧美日韩一区二区三区 | 国产精品一区二区不卡 | 免费人成在线观看视频色 | 免费一级毛片在线播放 | 中文字幕有码在线播放 | 一级特黄录像免费播放肥 | 麻豆专区 | 午夜影院色 | 日日好吊妞 | 一本大道香蕉大vr在线吗视频 | 视频一区 国产 | 国产日韩欧美综合在线 | 在线天堂在线 | 免费黄色毛片视频 | 免费777my性欧美另类 | 日韩毛片网 | 国产在线91精品天天更新 | 一个人免费观看的www视频 | 中文字幕一区二区在线播放 | 看片网站免费 | 欧美激情综合亚洲一二区 | 黄色小视频免费网站 | h国产| 日韩免费三级 | 成人一级黄色毛片 | 高清中文字幕在线 |