1. 使用的extentreports生成的测试报告, 报告中使用的css文件需要上强(墙)
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
测试方法
package com.actiger.reports;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.Test;
public class TestReport {
@Test
public void test1(){
Assert.assertEquals(1,2);
}
@Test
public void test2(){
Assert.assertEquals(1,1);
}
@Test
public void test3(){
Assert.assertEquals(3,3);
}
@Test
public void log1(){
Reporter.log("这是日志");
throw new RuntimeException("这是一个异常");
}
}
配置的xml
<?xml version="1.0" encoding="UTF-8" ?>
<suite name="mytest">
<test name="test">
<classes>
<class name="com.actiger.reports.TestReport">
<method>
<include name="test1"></include>
<include name="test2"></include>
<include name="test3"></include>
<include name="log1"></include>
</method>
</class>
</classes>
</test>
<listeners>
<listener class-name="com.vimalselvam.testng.listener.ExtentTestNgFormatter"></listener>
</listeners>
</suite>
运行xml, 并打开test-output中report.html即可查看