qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請(qǐng)?jiān)L問 http://qaseven.github.io/

          TestNg測(cè)試框架使用

          安裝Eclipse插件
            For Eclipse 3.4 and above, enter http://beust.com/eclipse.
            For Eclipse 3.3 and below, enter http://beust.com/eclipse1.
            Maven支持TestNG
          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>com.homeinns.web</groupId>
          <artifactId>homeinns-testng</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <packaging>jar</packaging>
          <name>homeinns-testng</name>
          <url>http://maven.apache.org</url>
          <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          </properties>
          <dependencies>
          <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>6.1.1</version>
          <scope>test</scope>
          </dependency>
          </dependencies>
          <build>
          <plugins>
          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.16</version>
          <configuration>
          <suiteXmlFiles>
          <suiteXmlFile>testng.xml</suiteXmlFile>
          <!-- <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> -->
          </suiteXmlFiles>
          </configuration>
          </plugin>
          </plugins>
          </build>
          </project>
           配置TestNg suite
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
          <suite name="Suite" parallel="none">
          <!--enabled="true"讓測(cè)試生效,也可根據(jù)情況關(guān)閉某些測(cè)試 -->
          <test name="Test" enabled="true">
          <!--指定參數(shù) -->
          <parameter name="Name" value="Irving" />
          <parameter name="Sex" value="Man" />
          <!--指定測(cè)試包 -->
          <packages>
          <package name="com.homeinns.web.testng.*" />
          </packages>
          <!--指定測(cè)試類 -->
          <classes>
          <class name="com.homeinns.web.testng.AppTest" />
          </classes>
          </test> <!-- Test -->
          </suite> <!-- Suite -->
          TestNg注解配置
          public class NgTest {
          @Test
          public void f() {
          }
          @Test(
          // 在指定的時(shí)間內(nèi)啟用3個(gè)線程并發(fā)測(cè)試本方法10次
          threadPoolSize = 3, invocationCount = 10, timeOut = 10000,
          // 等待測(cè)試方法t0測(cè)試結(jié)束后開始本測(cè)試
          dependsOnMethods = { "f" },
          // 指定測(cè)試數(shù)據(jù)源CLASS和數(shù)據(jù)源名稱(參考注解@DataProvider),返回幾條數(shù)據(jù)會(huì)跑測(cè)試方法幾次
          dataProvider = "generate", dataProviderClass = GeneratorRandomNum.class,
          // 分組名稱
          groups = { "checkin-test" })
          // 讀取配置文件中的參數(shù),配置如上,用@Optional設(shè)置默認(rèn)值
          @Parameters({ "Name" })
          public void f1(@Optional("name") String name) {
          }
          }
            測(cè)試報(bào)告
            運(yùn)行測(cè)試后 在my-testng/test-output/ 目錄下(maven \target\surefire-reports)
            gradle配置
          subprojects {
          apply plugin: 'java'
          // Disable the test report for the individual test task
          test {
          reports.html.enabled = false
          }
          }
          task testReport(type: TestReport) {
          destinationDir = file("$buildDir/reports/allTests")
          //Include the results from the `test` task in all subprojects
          reportOn subprojects*.test
          }Grouping TestNG tests
          test {
          useTestNG {
          excludeGroups 'integrationTests'
          includeGroups 'unitTests'
          }
          }

          posted on 2014-08-11 09:46 順其自然EVO 閱讀(536) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2014年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 施秉县| 弥勒县| 灯塔市| 扶绥县| 江永县| 佛学| 抚州市| 梁河县| 二手房| 当阳市| 佳木斯市| 忻城县| 连云港市| 卫辉市| 新泰市| 璧山县| 绍兴县| 大洼县| 澳门| 贵溪市| 汉阴县| 靖边县| 合川市| 遂昌县| 武强县| 元朗区| 湘潭市| 金溪县| 子长县| 武陟县| 天全县| 盱眙县| 固安县| 鹿邑县| 扎兰屯市| 大英县| 灵川县| 新营市| 壶关县| 克拉玛依市| 清流县|