为什么黄瓜不执行我的步骤定义
Why is Cucumber not executing my step definitions?
在Windows上工作,我已经安装了Ruby和Ruby DevKit,以便与Cucumber一起工作。现在我有以下基本设置:
/app
/features
example.feature
/step_definitions
example.steps.js
在示例功能文件中,我有:
Feature: This is an example feature
In order to learn Cucumber
As a developer
I want to make this feature pass
Scenario: wrote my first scenario
Given a variable set to 1
When I increment the variable by 2
Then the variable should contain 3
在 example.step.js 文件中,我有:
'use strict';
module.exports = function () {
this.givenNumber = 0;
this.Given(/^a variable set to ('d+)$/, function(number, next) {
this.givenNumber = parseInt(number);
next();
});
this.When(/^I increment the variable by ('d+)$/, function (number, next) {
this.givenNumber = this.givenNumber + parseInt(number);
next();
});
this.Then(/^the variable should contain ('d+)$/, function (number, next) {
if (this.givenNumber != number)
throw(new Error("This test didn't pass, givenNumber is " + this.givenNumber + " expected 0"));
next();
});
};
现在,当我从/app dir 运行"黄瓜"时,我不断获得以下输出:
1 scenario (1 undefined)
3 steps (3 undefined)
0m0.004s
我尝试在文件中移动,添加 --require 选项等,但似乎没有任何帮助。
有什么想法吗?
显然这不能直接使用"cucumber"命令执行。使用咕噜声设置事情,咕噜黄瓜任务似乎按预期工作:
我的咕噜咕噜.js
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cucumberjs: {
src: 'features',
options: {
steps: 'features/step_definitions',
format: 'pretty'
}
}
});
grunt.loadNpmTasks('grunt-cucumber');
grunt.registerTask('default', ['cucumberjs']);
};
另外:如果您使用的是量角器。它内置了黄瓜。只需为量角器创建正确的配置(protractor.conf.js):
exports.config = {
specs: [
//'e2e/features/*.feature'
'**/*.feature'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:9000/',
framework: 'cucumber'
}
相关文章:
- 如何让typeahead在我的搜索栏中填充自定义参数
- 自定义运行时Can'在谷歌应用引擎中看不到我的自定义日志
- 为什么获胜'我的自定义功能工作
- 为什么typeof的数组的数组的未定义值返回为“0”;未定义的“;我的条件不认为是真的
- 尝试使用Node.js动态路由从IMDB中抓取电影内容.但是在我的output.json文件中没有定义
- "TypeError:t.start未定义”;,在fullcalendar.min.js中,同时在我的网站上使
- 我的函数返回“未定义”
- 为什么我的Mongoose DB模式之一可能是“;强制转换为未定义的“;当它的实例被放置在第二个模式中时
- 为什么我的程序提醒未定义的值
- 如何将我的自定义时间选择器链接到我的asp.net
- JSHint 错误:未定义我的应用程序 (W117)
- 尝试从我的 chrome 扩展程序访问 gmail 中的 iframe 时出现未定义的错误,但不是从开发者控制台访问
- 为什么我的自定义过滤器会导致无限消化
- 为什么自定义 JavaScript 文件放在客户端文件夹中时不在我的 Meteor 模板上呈现
- RequireJS 2.0-定义我的Backbone.Return
- 为什么在使用requirejs定义我的模块时需要返回
- 自定义我的 jQuery 手风琴
- 函数未定义..我的函数调用不起作用
- 我如何使用外部路由.js,这样我就不必在app.js中定义我的路由了
- 定义我的导航的JSON有标题类型和类别类型;d希望转换为Javascript中的嵌套UL LI元素