黄瓜与量角器json报告

时间:2017-04-30 19:48:01

标签: protractor cucumber

我已经实现了黄瓜量角器示例,当我添加

时它工作正常
resultJsonOutputFile: 'report.json'  

生成json报告,如果所有步骤都成功,生成的报告如果一步失败则报告未生成,是否有人有任何理由为何会发生这种情况?

protractor.conf文件

   exports.config = {
      getPageTimeout: 600000,
      allScriptsTimeout: 700000,
      framework: 'custom',
      frameworkPath: require.resolve('protractor-cucumber-framework'),

      capabilities: {
        'browserName': 'chrome'
      },
      specs: [
        '/home/git/adap_gateway/src/test/features/*.feature'
      ],

      baseURL: 'http://localhost:8099/',

      cucumberOpts: {
        require: '/home/git/adap_gateway/src/test/javascript/stepDef/stepDefinitions.js',
      },
      resultJsonOutputFile: 'report.json'

    }; 

要素文件

Feature: Running Cucumber with Protractor

Scenario: Protractor and Cucumber Test
    Given I go to "http://localhost:8099/#/"
    When I add login credential 
    Then I go to scenario home page
    Then I go to scenario details page
    Then I go to edit attack tree page
    Then build attack tree

1 个答案:

答案 0 :(得分:1)

将json输出结果放入cucumberOpts。

尝试这样的事情:

cucumberOpts: {
    strict: true,    
    format: 'json:reports/current/cucumber_report.json', 
    'format-options': '{"colorsEnabled": true }',
    require: [
        'features/step_definitions/*.js', 
        'features/step_definitions/shared/*.js', 
        'support/*.js'
    ],
},