TA的每日心情 | 无聊 半小时前 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
Environment
1)OS:Window7 64bit
- OS 名称: Microsoft Windows 7 旗舰版
- OS 版本: 6.1.7601 Service Pack 1 Build 7601
- OS 制造商: Microsoft Corporation
复制代码 2)Eclipse:Oxygen Release (4.7.0)
3)java:1.8.0
- C:\Users\Administrator>java -version
- java version "1.8.0"
- Java(TM) SE Runtime Environment (build 1.8.0-b132)
- Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
复制代码 3)Software:Subclipse, subversion for eclipse -- 代码管理
selenium-server-standalone-2.53.0
testNG6.12
reportNG1.1.4
Deployment
1)下载并安装Eclipse
2)testNG插件:Help --> Eclipse Marketplace --> Search testNG: TestNG for Eclipse
3)reportNG插件:reportng-1.1.4.jar(http://www.grepcode.com/snapshot ... mons/reportng/1.1.4)
4)新建Java测试项目:File --> New --> Java Project: seAuto
5)新建package:src --> testSuite: testSuite
6)新建testNG:File --> Other --> TestNG --> TestNG class
Note: testNG具体说明,参考官方文档
7)引入testNG lib库
此时提示“The import org.testng cannot be resolved”,需要引用testNG lib库
Select Project --> Build Path --> Configure Build Path --> Libraries --> Add Library --> TestNG
8)验证testNG
testSuite.xml --> Run As --> TestNG Suite
此时会执行预设的测试,即testSuite.java中的标记为@test的测试 -- 参见,testSuite.java -- TestNG插件安装完毕
- [RemoteTestNG] detected TestNG version 6.12.0
- [TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your
- file, otherwise TestNG may fail or not work as expected.
- ===============================================
- Suite
- Total tests run: 2, Failures: 0, Skips: 0
- -
复制代码 使用reportNG插件
9)使用reporNG作为listeners: Window --> Preferences --> TestNG
10)testSuite.xml中注册reportNG
- <!-- add listener -->
- <listeners><listener class-name="org.uncommons.reportng.HTMLReporter"></listener></listeners>
复制代码 11)使用reportNG
执行测试工:testSuite.xml --> Run As --> TestNG Suite,提示如下
- [RemoteTestNG] detected TestNG version 6.12.0
- org.testng.TestNGException:
- Listener org.uncommons.reportng.HTMLReporter was not found in project's classpath
- at org.testng.TestNG.addListeners(TestNG.java:1009)
- at org.testng.TestNG.initializeConfiguration(TestNG.java:976)
- at org.testng.TestNG.initializeEverything(TestNG.java:1108)
- at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
- at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
- at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
- at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
复制代码- 添加reportNG lib库
- * Window --> Preferences --> Java --> Build Path --> User Libraries --> lib
- * Select Project --> Build Path --> Configure Build Path --> Libraries --> Add Library --> User Library: reportng1.1.4.jar
- 12)验证reportNG
- testSuite.xml --> Run As --> TestNG Suite
- [RemoteTestNG] detected TestNG version 6.12.0
- ===============================================
- Suite
- Total tests run: 2, Failures: 0, Skips: 0
- ===============================================
- 生成test-output目录,即reportNG报告
- Note: 在执行过程中会提示安装velocity 和 guice 插件,具体可参考Question 2
- 至此,Selenium + testNG + reportNG环境部署完成。
复制代码
|
|