我正在尝试创建一个 grunt 任务来运行 cucumber.js 测试。这些测试是在我的项目中的功能“区域”中组织的,例如:
project_root
--test
--spec-e2e
--home_Page
--features
--step_definitions
从我的项目的node_modules目录中,我可以手动运行cucumber.js,一切都很好:
$ node cucumber.js ../../../test/spec-e2e/home_Page/features/
输出:
1 scenario (1 passed)
3 steps (3 passed)
我似乎无法正确配置 grunt-cucumber 任务来重新创建相同的结果。 在我的 Gruntfile.js 中,我有以下配置:
// Cucumber test runner
cucumberjs: {
src: 'test/spec-e2e/home_Page/features',
options: {
steps: 'test/spec-e2e/home_Page/features/step_definitions',
format: 'pretty'
}
}
...
//Register task
grunt.registerTask('cucumber', ['cucumberjs']);
运行 $ grunt cucumber
只允许输出:
$ Running "cucumberjs:src" (cucumberjs) task
$ Done, without errors.
所以我没有收到任何错误或 cucumber 摘要输出。如果我故意编辑我的步骤定义之一而失败,结果总是相同的。有人可以告诉我如何正确配置吗?
谢谢!
最佳答案
试试这个:
请仔细阅读以下文档:
这段代码对我有用:
grunt.initConfig({
cucumberjs: {
all: {
src: 'features',
options: {
backtrace: true,
useShortStackTraces: false,
format: "json:<path where want to write json report>",
steps: 'features',
tags: grunt.option('feature')
}
}
});
grunt.registerTask('default', ['cucumberjs:all']);
关于node.js - grunt-cucumber 未运行 step_definitions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27112173/