zoukankan      html  css  js  c++  java
  • (十二)TestNG 生成测试报告

    TestNG 默认自带的有HTML格式的测试报告。这也充分说明拿它来做 UI 自动化测试的优势。

    通过 Maven 生成报告


    切换到 TestngTest 项目的跟目录下,通过 mvn test 命令运行测试。

    TestngTest> mvn test
    
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building TestngTest 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ TestngTest
     --- [WARNING] Using platform encoding (GBK actually) to copy filtered resources,
      i.e. build is platform dependent!
    [INFO] Copying 0 resource
    
    ...
    
    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running TestSuite
    Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@104e3b2
    Tests run: 19, Failures: 5, Errors: 0, Skipped: 2, Time elapsed: 3.862 sec <<< FAILURE!
    

    在该系列教程开始前,我已经说明了整个项目基于 Maven 创建。

    现在打开 ..TestngTest argetsurefire-reportsindex.html 将会看到整个项目的运行结果。

    通过 IntelliJ IDEA 生成测试报告


    在 IntelliJ IDEA 中默认运行测试用例是不会生成HTML报告的,需要进行简单的配置。

    菜单栏: “Run” -->“Edit Configuraction...” 。

    如上图,选择运行测试用例的 testng.xml 文件-->“Configuration”-->“Listeners”--> 勾选“Use default reporters” 选项, 最后点击“OK” 按钮, 完成设置。

    好了! 现在用 IntelliJ IDEA 运行 TestNG 测试用例一样可以生成报告了。

  • 相关阅读:
    BZOJ3573: [Hnoi2014]米特运输
    BZOJ3531: [Sdoi2014]旅行
    BZOJ3505: [Cqoi2014]数三角形
    BZOJ3309: DZY Loves Math
    BZOJ3260: 跳
    BZOJ3252: 攻略
    BZOJ3226: [Sdoi2008]校门外的区间
    BZOJ3155: Preprefix sum
    BZOJ2843: 极地旅行社
    BZOJ2671: Calc
  • 原文地址:https://www.cnblogs.com/xinlan06/p/11498792.html
Copyright © 2011-2022 走看看