如何保存量角器测试结果

时间:2014-05-13 14:50:47

标签: angularjs protractor

有没有办法在运行测试后将量角器测试结果输出到要在命令行之外查看的文件,包括查看详细的故障?

3 个答案:

答案 0 :(得分:7)

只是测试输出就够了吗?

protractor conf.js > test.log

干杯。

答案 1 :(得分:7)

我找到了一个很好的清洁方式,使用Jasmine记者以有序的方式保存测试结果。

如何安装和配置Jasmine记者:

安装Jasmine记者:

npm install -g jasmine-reporters

将以下内容添加到protractor-config.js文件中:

  onPrepare: function() {
    require('jasmine-reporters');
    jasmine.getEnv().addReporter(
      new jasmineReporters.JUnitXmlReporter('outputxmldir', true, true));
  }

创建outputxmldir文件夹(这是放置所有测试输出的地方)。

运行量角器,现在结果将导出到outputxmldir文件夹中的XML文件。

答案 2 :(得分:6)

您还可以在配置文件中设置 resultJsonOutputFile 选项:

export.config = {

   (...)

   // If set, protractor will save the test output in json format at this path.
   // The path is relative to the location of this config.
   resultJsonOutputFile:'./result.json',

   (...)

}

有关配置文件的更多详细信息,请访问:

https://raw.githubusercontent.com/angular/protractor/master/docs/referenceConf.js