51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1616|回复: 0
打印 上一主题 下一主题

seleninum + testNG + reportNG在Windows7搭建自动化测试环境

[复制链接]
  • TA的每日心情
    擦汗
    3 天前
  • 签到天数: 527 天

    连续签到: 4 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2018-11-29 15:00:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    Environment
    1)OS:Window7 64bit
    1. OS 名称:          Microsoft Windows 7 旗舰版
    2. OS 版本:          6.1.7601 Service Pack 1 Build 7601
    3. OS 制造商:        Microsoft Corporation
    复制代码
    2)Eclipse:Oxygen Release (4.7.0)
    3)java:1.8.0
    1. C:\Users\Administrator>java -version
    2. java version "1.8.0"
    3. Java(TM) SE Runtime Environment (build 1.8.0-b132)
    4. 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插件安装完毕
    1. [RemoteTestNG] detected TestNG version 6.12.0
    2. [TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your
    3.                               file, otherwise TestNG may fail or not work as expected.
    4. ===============================================
    5. Suite
    6. Total tests run: 2, Failures: 0, Skips: 0
    7. -
    复制代码
    使用reportNG插件
    9)使用reporNG作为listeners: Window --> Preferences --> TestNG
    10)testSuite.xml中注册reportNG
    1. <!-- add listener -->
    2. <listeners><listener class-name="org.uncommons.reportng.HTMLReporter"></listener></listeners>
    复制代码
    11)使用reportNG
            执行测试工:testSuite.xml --> Run As --> TestNG Suite,提示如下
    1. [RemoteTestNG] detected TestNG version 6.12.0
    2. org.testng.TestNGException:
    3. Listener org.uncommons.reportng.HTMLReporter was not found in project's classpath
    4.         at org.testng.TestNG.addListeners(TestNG.java:1009)
    5.         at org.testng.TestNG.initializeConfiguration(TestNG.java:976)
    6.         at org.testng.TestNG.initializeEverything(TestNG.java:1108)
    7.         at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
    8.         at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
    9.         at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    10.         at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
    复制代码
    1. 添加reportNG lib库
    2.     * Window --> Preferences --> Java --> Build Path --> User Libraries --> lib
    3.     * Select Project --> Build Path --> Configure Build Path --> Libraries --> Add Library --> User Library: reportng1.1.4.jar
    4. 12)验证reportNG
    5.     testSuite.xml --> Run As --> TestNG Suite
    6. [RemoteTestNG] detected TestNG version 6.12.0
    7. ===============================================
    8. Suite
    9. Total tests run: 2, Failures: 0, Skips: 0
    10. ===============================================
    11. 生成test-output目录,即reportNG报告
    12. Note: 在执行过程中会提示安装velocity 和 guice 插件,具体可参考Question 2

    13. 至此,Selenium + testNG + reportNG环境部署完成。
    复制代码



    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-18 04:48 , Processed in 0.062150 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表