我需要在每次运行的报告目录中分别保存每个报告文件。我们如何通过将当前日期和时间与文件名连接来创建报告文件。我在 TestRunnerTest.java 中使用了以下代码在黄瓜硒框架中生成 Extentreport。
package testRunner;
import java.io.File;
import java.io.IOException;
import java.nio.file.StandardCopyOption;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.vimalselvam.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources"
, glue= {"stepDefinition"}
, plugin = { "com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html"},
monochrome = true
)
public class TestRunnerTest {
public static WebDriver driver;
private static TestRunnerTest sharedInstance = new TestRunnerTest();
private TestRunnerTest() { }
public static TestRunnerTest getInstance() {
return sharedInstance;
}
@BeforeClass
public static void before() {
System.setProperty("webdriver.chrome.driver",
"E:\\ChromeDriverNew\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterClass
public static void after() {
Reporter.loadXMLConfig(new File("config/report.xml"));
driver.quit();
}
}
任何人都可以回答如何使用 Selenium-Cucumber Maven 框架在每次执行时生成报告日志。提前致谢
达令说
相关分类