缺少步骤 - Junit - 黄瓜

问题描述 投票:0回答:1

我在自动化代码中使用了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 {
}

在我的黄瓜功能:

@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运行时,它会显示以下消息:

您可以使用以下代码段实现缺少的步骤:@Given(“^ acessei a url do portal $”)

你能帮我解决一下吗?谢谢

junit cucumber cucumber-junit junit-runner
1个回答
0
投票

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

@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 {
}
© www.soinside.com 2019 - 2024. All rights reserved.