java - 如何使用 Selenium - Junit 测试运行程序文件和 cucumber 选项为每次运行创建测试结果文件夹?

标签 java selenium selenium-webdriver cucumber-junit

任何人都可以建议我,在 Cucumber 选项中使用“插件”或“格式”。如何为我们的每次运行创建单独的测试结果文件夹。

下面的代码行为结果创建公共(public)文件夹,如果我们运行脚本,当前存在的结果将被新的结果/报告替换。因此,我希望为每次运行创建包含日期和时间的新文件夹,以便存储结果。

import org.junit.runner.RunWith; 
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;  

@RunWith(Cucumber.class) 
@CucumberOptions(features = "src/test/resources/feature/", 
tags="@AppLaunch", 
glue = "com.org.frameworkFiles.stepDefinitions", 
plugin = {"pretty", "html:target/site/cucumber-pretty1","html:target/Masterthought"},
monochrome = true,
dryRun = true)

最佳答案

事情不是这样的。使用@RunWith(Cucumber.class)注释允许 JUnit 运行 Cucumber 场景,就像它们是常规单元测试一样。

假设您使用 Maven,测试结果最终会出现在模块的 target 目录中,该目录会在每次干净构建时删除并重新创建。

您想通过在目标目录中创建单独的报告文件夹来实现什么目的?除非更改源,否则每次运行的测试结果都是相同的,但这需要新的构建,从而删除所有报告。

关于java - 如何使用 Selenium - Junit 测试运行程序文件和 cucumber 选项为每次运行创建测试结果文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44797128/

相关文章:

java - 如何在接口(interface)中使用静态方法来返回实例方法返回的泛型实例?

java - Google Guice 找不到类(class)

python - 如何修复 selenium "DevToolsActivePort file doesn' t 在 Python 中存在“异常”

selenium - 查找带有闭合标签下方文本的 XPath

selenium - 实现jenkins docker image + chrome + ruby​​未知错误时出现问题:Chrome无法启动:崩溃(Selenium::WebDriver::Error::UnknownError)

c# - 使用 C# 在 Selenium WebDriver 中断言、验证和其他命令

java - 我需要在下拉框中滚动

java - 如何在 Spring 中排除/禁止 validator 中的字段

python - 无效元素状态异常 : Message: invalid element state: Element is not currently interactable and may not be manipulated

java - 即使有 try catch 也会获取 RuntimeException