TestNG自定義記錄器測(cè)試報(bào)告
創(chuàng)建 testng.xml
創(chuàng)建一個(gè)文件testng.xml 在 C: > TestNG_WORKSPACE 來(lái)執(zhí)行測(cè)試用例
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Simple Reporter Suite">
<listeners>
<listener class-name="CustomReporter" />
</listeners>
<test name="Simple Reporter test">
<classes>
<class name="SampleTest" />
</classes>
</test>
</suite>
編譯SampleTest,CustomReporter類使用javac
C:TestNG_WORKSPACE>javac CustomReporter.java SampleTest.java
運(yùn)行 testng.xml.
C:TestNG_WORKSPACE>java -cp "C:TestNG_WORKSPACE" org.testng.TestNG testng.xml
驗(yàn)證輸出
===============================================
Simple Reporter Suite
Total tests run: 3, Failures: 1, Skips: 1
===============================================
Passed tests for suite 'Simple Reporter Suite' is:1
Failed tests for suite 'Simple Reporter Suite' is:1
Skipped tests for suite 'Simple Reporter Suite' is:1
前面的例子顯示了一個(gè)簡(jiǎn)單的自定義報(bào)告器,打印的數(shù)量在控制臺(tái)上對(duì)每個(gè)套件包含在上述的測(cè)試執(zhí)行失敗,通過(guò)跳過(guò)測(cè)試。報(bào)告器主要是用于測(cè)試的執(zhí)行,以生成終的報(bào)告。擴(kuò)展程序可以被用來(lái)生成XML,HTML,CHM,CSV或文本格式的文件,根據(jù)報(bào)告要求。