2015-01-26 11 views
1

Работая над Windows, я установил Ruby и Ruby DevKit, чтобы получить работу с Cucumber. Теперь у меня есть следующие основные настройки:Почему Огурец не выполняет определения моего шага?

/app 
    /features 
     example.feature 
     /step_definitions 
      example.steps.js 

В файле example.feature у меня есть:

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, я продолжаю получать следующий вывод:

1 scenario (1 undefined) 
3 steps (3 undefined) 
0m0.004s 

Я попытался перемещаться по файлам, добавив параметр --require и т. Д., Но ничего не помогает.

Любые идеи?

ответ

0

По-видимому, это невозможно выполнить непосредственно с помощью команды «огурец». Настройки вещи вверх с помощью хрюканье и grunt-cucumber задачу, кажется, работает, как ожидалось:

Мой Gruntfile.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' 
} 
Смежные вопросы