缺少步骤 - Junit - 黄瓜
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了缺少步骤 - Junit - 黄瓜相关的知识,希望对你有一定的参考价值。
我在自动化代码中使用了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 $”)
你能帮我解决一下吗?谢谢
答案
请尝试在文件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 {
}
以上是关于缺少步骤 - Junit - 黄瓜的主要内容,如果未能解决你的问题,请参考以下文章