一、eclipse 中配置testng
1.1 安裝Testng
Help >> Install New Software >>
點擊Add然后隨便輸入一個名字,地址輸入:https://dl.bintray.com/testng-team/testng-eclipse-release/
確認之后會進行檢索,如下圖:

下一步并同意協議即可進行安裝,
二、撰寫程式測驗
2.1 單瀏覽器測驗
撰寫如下代碼:
點擊 Run As 會出現Testng的選項,如果你的沒有,可能是你的Testng沒有安裝或沒有安裝成功,

當你在src/main/java撰寫測驗代碼的時候,可能會出現無法參考Testng的情況,這可能是因為你在pom.xml檔案中進行了限制,

完整pomx.xml代碼如下:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.amnotgcs</groupId>
<artifactId>amnotgcs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<!-- <scope>test</scope> -->
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
更多關于maven配置的資訊,可參考Testng官網或者mavenrepository.com自行搜索添加
2.2 測驗結果:
測驗結果如下圖:

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/160088.html
標籤:其他
