Is there a way to run protractor tests in parallel

2019-04-28 03:27发布

问题:

I am facing synchronisation issues with my protractor tests and I would like to run my tests in parallel in contrast to my actual settings. In fact at the moment my tests run one after the other. I know how to this with TestsNG not sure how to do it with Jasmin Framework?

回答1:

Since 0.19.0 version of Protractor, you can run tests in parallel using the multiCapabilities option:

protractor.conf.js

multiCapabilities: [{
  'browserName': 'chrome'
}, {
  'browserName': 'chrome'
}]

from Browser setup - Protractor docs

This issue seems to fit your case.

For now, Protractor doesn't allow to set Webdriver maxSessions option, there is a more global discussion to include this feature among others.

EDIT: multiCapabilities was introduced to run tests in parallel under different browsers, but in your case, you can use it to run multiple instances of the same ;)



回答2:

To split tests between two browsers,

  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2
  },


回答3:

multiCapabilities: [
    {
        "browserName": "chrome",        
        shardTestFiles: true,
        maxInstances: 2,
        specs: ['login.js', 'login2.js', 'login.js', 'login2.js']
    },
    {
        "browserName": "firefox",
        "count": 1
        specs: ['login2.js']
    },
],

You can use both "count" as well "maxInstances" This is what worked best for me ..

            "browserName": "chrome",        
            shardTestFiles: true,
            maxInstances: 2,
            specs: ['login.js', 'login2.js', 'login.js', 'login2.js']

this would run 4 tests divided equally(or may not equally) in two different chrome browsers.