【问题标题】:grunt-cucumber not running step_definitionsgrunt-cucumber 没有运行 step_definitions
【发布时间】:2019-08-01 21:29:29
【问题描述】:

我正在尝试创建一个 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.

所以我没有收到任何错误或黄瓜摘要输出。如果我故意编辑我的 step_definitions 之一以失败,结果总是相同的。有人能告诉我如何正确配置吗?

谢谢!

【问题讨论】:

  • 您使用的是 st9pepper 的插件吗?如果是这样,我不会推荐它,因为 st9pepper 似乎没有维护他的模块(grunt-jasmine-node 是另一个)。我会使用这个:npmjs.org/package/grunt-cucumberjs,它似乎维护得更好,而且可能更好用。应该也可以解决您的问题

标签: node.js gruntjs cucumberjs


【解决方案1】:

试试这个:

请浏览以下文档:

Grunt cucumber js docs

此代码适用于我:

     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']);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 1970-01-01
    相关资源
    最近更新 更多