您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > TestNG
在Eclipse中使用Maven配置WebDriver+Testng(1)
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2014/3/6 9:59:53 ] 推薦標(biāo)簽:Testng Eclipse Maven

  建立Maven項目:有2種常見的方法,方法2的優(yōu)點暫時還不是太了解,但是我看網(wǎng)上很多人都是用的方法2。。。
  方法1:
  eclipse中建立Maven項目,修改pom.xml(同方法2代碼)后執(zhí)行Run As: Maven install.
  方法2:
  1. 下載Maven并配置環(huán)境變量 (mvn 的安裝見 http://maven.apache.org/download.html)
  設(shè)置變量名: M2_HOME=Maven安裝目錄
  設(shè)置path: 把%M2_HOME%in添加到path變量中
  2. cmd命令行新建一個Maven項目
  mvn archetype:generate -DgroupId=com.testM2 -DartifactId=my_testng_test -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  下面解釋一下運行的命令的含義:
  創(chuàng)建項目 archetype:generate
  設(shè)定項目代碼的包名 -DgroupId
  指定項目名 -DartifactId
  指定生成項目所使用的類型 -DarchetypeArtifactId
  是否與Maven交互,-DinteractiveMode=false, 如果不指定或者設(shè)成true在創(chuàng)建過程中要還要設(shè)定幾個值,比如打包類型、版本號的格式等等。
  3. 找到該文件夾,修改pom.xml 添加以下selenium 和 testng 依賴,刪除掉默認(rèn)的junit依賴
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testM2</groupId>
<artifactId>my_testng_test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my_testng_test</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.7</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd