2016-09-30 82 views
2

背景:我使用Jasmine作为我的量角器测试框架,我一直在使用jasmine spec reporter进行报告。昨天我稍微改变了我的量角器conf.js我jasmineNodeOpts参数包括print()功能即JasmineNodeOpts - 打印量角器测试结果

jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 120000, 
    includeStackTrace : true, 
    isVerbose : true, 
    print: function() {} 
}, 

,因为我学会了将各自报告之前删除.我加入这个打印功能。例如,用我的测试报告回来:

. ✓ should display a profile question about IT loads 
. ✓ checks the width of the progress bar 
. ✓ selects an option from the radio buttons and updates the progress bar 

而现在这些领先的点都被删除。不过,现在我的最终报告也略有改变来自:

14 specs, 2 failures Finished in 45.473 seconds // this is the old, desired output 

要这样:

Executed 14 of 14 specs (2 FAILED) in 45 secs. // this is my current, undesired output 

我想两全其美的,具有.从我的报告中删除,但保留了以前的总报告。

问题:我不能jasmineNodeOpts和/或print()功能找到详细文档。它在jasmine-spec-reporterprotractor reference conf中被提及,但是它没有真正的工作原理文档,只提供了很弱的例子。

有谁知道我在哪里可以了解更多关于这个print()函数和/或如何更改我的最终测试输出?

回答

1

我对这种情况有一个解决方案。这是怎样的一个黑客,在jasmine-spec-reporter一个小的变化 - 与下面的逻辑

summary: function (metrics) { 

    this.log(metrics.executedSpecs + ' specs, ' + metrics.failedSpecs+ ' failures Finished in ' + metrics.duration); 
    if (metrics.random) { 
     this.log('Randomized with seed ' + metrics.seed + '.'); 
    } 
    }, 

我刚才检查和其产生的执行摘要,你是summary(metrics)node_modules/jasmine-spec-reporter/src/spec-display.js - displaySummary逻辑

更换方法期待

Spec started 

    - sample test 
    √ Dummy Test 
    √ Dummy Test2 
    √ Dummy Test3 


3 specs, 0 failures 
Finished in 27.544 seconds 

    3 specs,0 failures Finished in 28 secs 
+0

太棒了,谢谢你。完美工作。不知道为什么我自己没有想到编辑记者,我被困在如何配置'print()'函数:) – Gunderson

+0

Np ..很高兴它工作! – AdityaReddy