【问题标题】:Missing steps - Junit - Cucumber缺少的步骤 - Junit - Cucumber
【发布时间】:2018-11-08 12:27:03
【问题描述】:

我在我的自动化代码中使用 cucumber 和 Junit,我使用以下代码创建了一个 Runner 类:

@RunWith(Cucumber.class) 
@CucumberOptions(features = "src/main/java/CompraVtex/CompraVtex/VtexCompra.feature", glue = { "Steps" }, plugin = {
    "pretty", "html:target/cucumber-reports" }, monochrome = true, dryRun = false)

public class Runner {
}

关于我的 Cucumber 功能:

@tag1
Scenario: Acessando Portal Receba em Casa
Given acessei a url do portal
And cliquei no botao de Login com google
And Mudei o foco para a tela do Pop Up

在我的 Steps 课上:

public class Steps extends Execute {


    @Test(priority=1)
    @Given("acessei a url do portal")
    public void AcessoUrl() {
           Execute Executar = new Execute();
           Executar.abrirBrowser();
    }

    @Test(priority=2)
    @And("cliquei no botao de Login com google")
    public void Login() throws Exception {
        Execute Executar = new Execute();
        getscreenshot("01 Login","01 - Acessando URL"); 
        Executar.Login();
    }

但是当我尝试使用 Junit 运行时,它会显示以下消息:

您可以使用下面的 sn-ps 实现缺少的步骤: @Given("^acessei a url do portal$")

你能帮我解决它吗?谢谢

【问题讨论】:

标签: junit cucumber cucumber-junit junit-runner


【解决方案1】:

请尝试在文件 Cucumber Feature 中添加标签名称:

@RunWith(Cucumber.class) 
@CucumberOptions(features = "src/main/java/CompraVtex/CompraVtex/VtexCompra.feature", glue = { "Steps" },tags = {"@tag1"}, plugin = {
    "pretty", "html:target/cucumber-reports" }, monochrome = true, dryRun = false)

public class Runner {
}

【讨论】:

    猜你喜欢
    • 2022-01-16
    • 2018-11-27
    • 2022-06-28
    • 1970-01-01
    • 2019-11-19
    • 2021-08-07
    • 2022-11-10
    • 1970-01-01
    • 2019-08-11
    相关资源
    最近更新 更多