缺少步骤-Junit-黄瓜

时间:2018-11-08 12:27:03

标签: junit cucumber cucumber-junit junit-runner

我在自动化代码中使用了黄瓜和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

在“我的步骤”课程中:

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 $”)

您能帮我解决吗?谢谢

1 个答案:

答案 0 :(得分:0)

请尝试在文件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 {
}