0

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

在我的步骤课上:

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

你能帮我修一下吗?谢谢

4

1 回答 1

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 {
}
于 2018-12-10T08:07:15.187 回答