2017-06-02 36 views
0

我已经在本地安装了npm模块(在下面的package.json中找到依赖关系的详细信息),并尝试执行下面的cucumber功能文件和SD,但是获取未定义。执行..消息。在Cucumber量角器设置中获取未定义的步骤定义警告

我已准备了我的特征文件,如下:在存储:测试/功能/ sample.feature

Feature: Running Cucumber with Protractor 
@test 
Scenario: To verify the Search result 
    Given I am on home page 

并实现了如下的SD:储存在:测试/ step_definitions/sample.steps .js文件

module.exports = function() { 
    this.Given(/^I am on home page$/, function() { 
    return browser.get("http://www.google.com"); 
    }); 
} 

而且我规格& cucumberOpts在如下conf.js:

specs: [ 
'./../features/*.feature' 
], 

cucumberOpts: { 
    require: ['./step_definitions/*.steps.js'], 
    tags: '@test', 
    strict: true, 
    format: 'pretty' 
} 

安装的package.json依赖性的详细信息:

"dependencies": { 
    "chai": "^4.0.1", 
    "chai-as-promised": "^6.0.0", 
    "cucumber": "^2.3.0", 
    "protractor": "^5.1.2", 
    "protractor-cucumber-framework": "^3.1.1" 
} 

但在执行中得到消息:

1 scenario (1 undefined) 
1 step (1 undefined) 
0m00.000s 

有人能帮助我走出来......

回答

2

你的问题似乎是与步骤定义本身。

您似乎对2.x框架使用旧的CucumberJS 1.x语法。

下面是使用2.x的语法提供的更新步骤定义:

var {defineSupportCode} = require('cucumber'); 

defineSupportCode(({Given, When, Then}) => { 

    Given(/^I am on home page$/, function() { 
    return browser.get("http://www.google.com"); 
    }); 

}); 
相关问题