2014-07-17 115 views
12

在我的业力测试中使用Chrome时,我经常(超过所有运行的50%)看到每次测试都由Chrome执行两次。您可以在下面找到示例输出和我的配置。Chrome在业力运行测试两次

我该如何解决这个问题?原因是什么?

karma start --single-run --browsers Firefox,Chrome 

INFO [karma]: Karma v0.12.17 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser Firefox 
INFO [launcher]: Starting browser Chrome 

INFO [Chrome 36.0.1985 (Linux)]: Connected on socket RV8G8p63bCLQGaAJW9Hc with id 91444447 
Chrome 36.0.1985 (Linux): Executed 0 of 92 SUCCESS (0 secs/0 secs) 
Chrome 36.0.1985 (Linux): Executed 1 of 92 SUCCESS (0 secs/0.065 secs) 
[...] 
Chrome 36.0.1985 (Linux): Executed 91 of 92 SUCCESS (0 secs/0.24 secs) 
Chrome 36.0.1985 (Linux): Executed 92 of 92 SUCCESS (0 secs/0.241 secs) 
Chrome 36.0.1985 (Linux): Executed 92 of 92 SUCCESS (0.274 secs/0.241 secs) 
Chrome 36.0.1985 (Linux): Executed 93 of 92 SUCCESS (0.274 secs/0.258 secs) 
[...] 
Chrome 36.0.1985 (Linux): Executed 183 of 92 SUCCESS (0.274 secs/0.412 secs) 
Chrome 36.0.1985 (Linux): Executed 184 of 92 SUCCESS (0.274 secs/0.413 secs) 

INFO [Iceweasel 30.0.0 (Linux)]: Connected on socket 4DISHs7012QeIwhEW9Hd with id 93232241 

Chrome 36.0.1985 (Linux): Executed 184 of 92 SUCCESS (0.274 secs/0.413 secs) 
Iceweasel 30.0.0 (Linux): Executed 0 of 92 SUCCESS (0 secs/0 secs) 
Chrome 36.0.1985 (Linux): Executed 184 of 92 SUCCESS (0.274 secs/0.413 secs) 
Iceweasel 30.0.0 (Linux): Executed 1 of 92 SUCCESS (0 secs/0.003 secs) 
[...] 
Iceweasel 30.0.0 (Linux): Executed 91 of 92 SUCCESS (0 secs/0.201 secs) 
Chrome 36.0.1985 (Linux): Executed 184 of 92 SUCCESS (0.274 secs/0.413 secs) 
Iceweasel 30.0.0 (Linux): Executed 92 of 92 SUCCESS (0 secs/0.202 secs) 
Chrome 36.0.1985 (Linux): Executed 184 of 92 SUCCESS (0.274 secs/0.413 secs) 
Iceweasel 30.0.0 (Linux): Executed 92 of 92 SUCCESS (0.303 secs/0.202 secs) 
TOTAL: 276 SUCCESS 

配置:

module.exports = function(config) { 
    config.set({ 

    basePath : 'www', 

    frameworks : [ 'jasmine' ], 

    files : [ 'js/*' ], 

    exclude : [ 'spec/lib/*.js' ], 

    reporters : [ 'progress', 'junit', 'html', 'coverage' ], 

    coverageReporter : { 
     type : 'html', 
     dir : 'coverage/' 
    }, 

    preprocessors : { 
     'js/*.js' : 'coverage', 
    }, 

    junitReporter : { 
     outputFile : 'test-results.xml' 
    }, 

    colors : true, 

    logLevel : config.LOG_INFO, 

    autoWatch : true, 

    browsers : [ 'Firefox', 'Chrome' ], 

    captureTimeout : 20000, 

    reportSlowerThan : 500, 

    plugins : [ 'karma-jasmine', 'karma-coverage', 'karma-html-reporter', 'karma-chrome-launcher', 'karma-junit-reporter', 'karma-phantomjs-launcher', 'karma-firefox-launcher' ] 

    }); 
}; 
+0

你的配置文件是怎样的? – andreaspfr

+0

@ seven-ply http://paste.debian.net/110248/ –

+0

当您启动测试时,Chrome上是否有现有选项卡?有时我也遇到了与Safari相同的问题,通常就是这样。 – MarcoL

回答

0

对我来说,铬50%的病例是乳宁脚本两次,因为我没有favicon.ico的了。花了我一天的时间找出它:) 您的图标是否出现在Chrome浏览器中? 如果没有,Chrome寻找favicon.ico,并且如果您的网站使用相同的php代码返回404页面,则chrome会执行两次。

<link rel="icon" href="/favicon.ico" sizes="32x32" type="image/png" /> 
+0

我不使用网络服务器,所以没有404代码。据我所知,这个图标是可选的。 –

0

您必须包括其运行其自己的一套测试用例因缘测试用例

6

我知道这是一个老问题b对我来说,问题是在业务配置文件中设置reporters

我: reporters: ['progress', 'dots', 'junit']

运行进步导致测试运行两次(或者更确切地说,显示它运行两次)。

因此,解决方案是让这些记者中的一位不在。

+0

同样在这里,我的问题也是在记者面前。 +1 – yl2015

0

这发生在我身上,只是因为我打开了另一个Chrome选项卡并指向Karma服务器。

0

这发生在我身上,因为我没有在Karma Run/Debug配置中指定浏览器。 在“浏览器启动”下指定(如下所示)。

enter image description here