java - 无法生成范围报告
问题描述
我正在尝试使用 JUnit 在 Selinium 中生成一个简单的范围报告。但它没有生成 html 报告,我什至一直在更改目录路径。单元测试运行正常,没有显示任何错误,只是找不到 html 文件。如果缺少某些内容,请告诉我。
pom.xml
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
</dependencies>
测试类
@SpringBootTest
@RunWith(SpringRunner.class)
public class CmsAutomatApplicationTests {
public static WebDriver driver;
static ExtentReports extent;
static ExtentTest test;
static ExtentHtmlReporter htmlReporter;
public static final String REPORT_FILE_PATH =System.getProperty("user.dir")+"/Automation_Reports/";
@BeforeClass
public static void startReport(){
extent = new ExtentReports();
htmlReporter = new ExtentHtmlReporter("C:\\Test-Automation-Report.html");
htmlReporter.config().setTheme(Theme.DARK);
htmlReporter.config().setEncoding("utf-8");
htmlReporter.config().setReportName("Automation Test Results");
htmlReporter.config().setEncoding("utf-8");
htmlReporter.config().setJS("$('.brand-logo').text('CMS');");
htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");
extent.attachReporter(htmlReporter);
extent.setSystemInfo("OS", System.getProperty("os.name"));
extent.setSystemInfo("Java", System.getProperty("java.specification.version"));
extent.setSystemInfo("User", System.getProperty("user.name"));
}
@Test
public void extentReportsDemo()
{
test= extent.createTest("test 1");
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.co.in");
if(driver.getTitle().equals("Google"))
{
test.log(Status.PASS, "Navigated to the specified URL");
}
else
{
test.log(Status.FAIL, "Test Failed");
}}
@AfterClass
public static void endTest()
{driver.quit();
extent.removeTest(test);
extent.flush();
}
}
解决方案
推荐阅读
- html - 使用谷歌脚本将页面(链接)放在侧边栏中
- reactjs - 如何从 ReactJS 中的 OpenLayers Map 获取坐标?
- c# - 当 ItemSource 初始化为空时,Xamarin 表单控件未显示
- java - 将 Firebase 字符串数组检索到数组
- apache-zookeeper - Apache Flink Zookeeper 升级后检查点冲突
- smalltalk - 我们如何在不实例化操场上的对象的情况下运行 pharo 程序?
- c# - 如何使 WPF AutoCompleteBox 接受多个属性进行过滤
- javascript - 表单提交两次
- javascript - 从stackoveflow打开链接时没有出现document.referrer
- pandas - Pandas 在自定义开始时间戳重新采样