2016-06-01 15 views
0

キュウリJSのサンプルは私のローカルシステム私は私のローカルのWindowsシステムにキュウリ-jsからサンプルプログラム<a href="http://cucumber.github.io/cucumber-js/" rel="nofollow">http://cucumber.github.io/cucumber-js/</a>を実行しようとしています

ノードバージョン0.10.26 NPMのバージョンでは動作しない1.4.3

フォルダ構造

../node_modules ../test/features/support/world.js ../test/feaトゥーレス/ new_math.js ../test/features/step_definitions/demonstrationSteps.js

//steps code 
module.exports = function() { 
this.World = require("../support/world").World; 

this.Given(/^a variable set to (\d+)$/, function(number) { 
    this.setTo(number); 
}); 

this.When(/^I increment the variable by (\d+)$/, function(number) { 
    this.incrementBy(number); 
}); 

this.Then(/^the variable should contain (\d+)$/, function(number) { 
    if (this.variable != parseInt(number)) 
    throw new Error('Variable should contain ' + number + 
     ' but it contains ' + this.variable + '.'); 
}); 
}; 

ワールドファイル:

var CustomWorld = function() {}; 

CustomWorld.prototype.variable = 0; 

CustomWorld.prototype.setTo = function(number) { 
    this.variable = parseInt(number); 
}; 

CustomWorld.prototype.incrementBy = function(number) { 
    this.variable += parseInt(number); 
}; 

module.exports.World = CustomWorld; 

フィーチャーファイル:私は実行

Feature: Simple maths 
    In order to do maths 
    As a developer 
    I want to increment variables 

    Scenario: easy maths 
    Given a variable set to 1 
    When I increment the variable by 1 
    Then the variable should contain 2 

    Scenario Outline: much more complex stuff 
    Given a variable set to <var> 
    When I increment the variable by <increment> 
    Then the variable should contain <result> 

    Examples: 
     | var | increment | result | 
     | 100 |   5 | 105 | 
     | 99 |  1234 | 1333 | 
     | 12 |   5 |  18 | 

"cucumber-js/test/features/new_math.feature"というコマンドは、コマンドプロンプトで次のように出力されます。

Feature: Simple maths 
    In order to do maths 
    As a developer 
    I want to increment variables 

答えて

0

私は、コマンド "NPMテスト" を使うときにスクリプト

"scripts": { 
    "test": "cucumber-js test/features/demonstration.feature" 
    }, 

をトリガするために、私のpackage.jsonを構成し、周りの仕事を見つけました。機能が実行されていた。

関連する問題

 関連する問題