2017-03-07 99 views
0

我正在学习黄瓜日蚀中的BDD。我已经下载了所有的jar文件,但仍然是eclipse,它说它找不到其他文本的定义。黄瓜黄瓜问题 - 没有找到匹配的胶水代码

Feature: Login 

Scenario: Successful Login with valid Credentials 
    Given user is on Homepage 
    When user enters Username and Password 
    Then He can visit the practice page 

在上面的代码,它找不到胶水代码如下文字:

  1. 用户在首页
  2. 用户输入用户名和密码
  3. 他可以参观实践页面
+0

请分享您的文件格式和跑步者等级。您遇到的问题可能有很多不同的原因,我们没有足够的信息来帮助您。 –

回答

0

你能粘贴你得到的确切错误吗?

你有step_definitions文件,你已经在features文件夹里面编写了小黄瓜步骤的代码吗?

0

检查这些选项

选项1: 确保您运行的代码,黄瓜功能并用黄瓜插件

Cucumber Plugin

在你的情况帮助产生的骨架,黄瓜将打印像这样

//Print start 
@Given("^user is on Homepage$") 
public void user_is_on_Homepage() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@When("^user enters Username and Password$") 
public void user_enters_Username_and_Password() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 

@Then("^He can visit the practice page$") 
public void he_can_visit_the_practice_page() throws Throwable { 
    // Write code here that turns the phrase above into concrete actions 
    throw new PendingException(); 
} 
//Print End 

创建程序包features.stepDefinitions然后creat具有上述生成的骨架的e类文件“ABC.java”。请继续选项2

选项2

如果下面的类是亚军,我们需要具有以下特征:文件夹的胶水。通常它会在资源文件夹

package test.runner 
import org.junit.runner.RunWith; 
import cucumber.api.CucumberOptions; 

@CucumberOptions(
      features="src/test/resources/features/featureFileFolder", 
      glue = { "features.stepDefinitions"}, 
      tags={"@UI"}, 
      monochrome=true) 
    public class Runner{ 

    } 

最后执行亚军文件作为JUnit测试

注:

标签UI是我们将使用链接的场景和注释。

在这种情况下,功能文件将写为。

@UI

情景:成功登录使用有效凭据

鉴于用户在首页

当用户输入用户名和密码

那么他就可以访问该页面的做法

希望这可以帮助!