如何保存量角器测试结果

Dom*_*X23 8 angularjs protractor

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

vto*_*ola 7

只是测试输出就足够了?

protractor conf.js > test.log
Run Code Online (Sandbox Code Playgroud)

干杯.


Dom*_*X23 7

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

如何安装和配置Jasmine记者:

安装Jasmine记者:

npm install -g jasmine-reporters
Run Code Online (Sandbox Code Playgroud)

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

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

创建outputxmldir文件夹(这是放置所有测试输出的位置).

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

  • 正确的方法是将 `require('jasmine-reporters')` 的输出保存到它自己的变量中(例如,`jasmineReporters`)。然后调用 `jasmineReporters.JUnitXmlReporter(...)` 而不是 `jasmine.JUnitXmlReporter(...)` (2认同)

Alm*_*pos 7

您还可以在配置文件中设置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',

   (...)

}
Run Code Online (Sandbox Code Playgroud)

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

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