【问题标题】:How to see my scenario names in Test Result in Java如何在 Java 中的测试结果中查看我的场景名称
【发布时间】:2019-06-19 23:25:40
【问题描述】:

在测试结果部分,类名称显示为 classMethod。我使用黄瓜测试库进行测试。在测试结果部分,我想查看我在功能文件中指定的“场景:”名称。我该怎么办?你能帮帮我吗?

build.gradle 文件:

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
testCompile("io.github.bonigarcia:webdrivermanager:3.+")
testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.+'
compile group: 'info.cukes', name: 'cucumber-java', version: '1.+'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
testCompile group: 'org.testng', name: 'testng', version: '6.14.3'
}

RunFeature 类:

package feature;

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

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/java/testCases" )
public class RunFeatures {
}

黄瓜功能:

Feature: OpenBrowser

Scenario: SelectBrowser
When I have opened "https://www.trendyol.com/" with "explorer" browser

【问题讨论】:

  • 您指的是要在其中添加场景名称的默认 html 报告吗?

标签: java selenium selenium-webdriver junit cucumber


【解决方案1】:

您可以使用以下代码在@before 挂钩中打印场景名称。

@Before
public void scenarioInit(Scenario scenario){
    String scenarioName = scenario.getName()
   //log the name to logger or to console here
}

您可以将名称记录到您的记录器或控制台中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多