protractor icon indicating copy to clipboard operation
protractor copied to clipboard

The specs cli param does not override specs in config file

Open psech opened this issue 11 years ago • 6 comments

The specs cli param does not override specs in config file (and I believe it should?) When both specs config property and the same --specs command-line argument are provided, whole tests are run twice.

Protractor: 1.4, 1.5 and probably earlier OS: Windows 7

File structure:

C:\...\TEST\TESTS\PRSE-SPLITTED
    prse.e2e.Model.js
    prse_1.e2e.js
    prse_2.e2e.js
    prse_3.e2e.js

Example config:

    maxSessions: 4,

    multiCapabilities: [
        {
            shardTestFiles: true,
            browserName: 'chrome',
            specs: ['../tests/prse-splitted/*.e2e.js']
        }
    ],

command line:

node node_modules\protractor\bin\protractor ^
  test\e2e\protractor-config_ci.js ^
  --specs=test\tests\prse-splitted\*.e2e.js

The output (six instead of three):

[chrome #1a] Specs: c:\...\test\tests\prse-splitted\prse_1.e2e.js
[chrome #1b] Specs: c:\...\test\tests\prse-splitted\prse_2.e2e.js
[chrome #1c] Specs: c:\...\test\tests\prse-splitted\prse_3.e2e.js
[chrome #1d] Specs: c:\...\test\tests\prse-splitted\prse_1.e2e.js
[chrome #1e] Specs: c:\...\test\tests\prse-splitted\prse_2.e2e.js
[chrome #1f] Specs: c:\...\test\tests\prse-splitted\prse_3.e2e.js

psech avatar Dec 09 '14 03:12 psech

I suspect this is happening only when sharding is true (as I've testing without sharding recently and it's working fine)- @hankduan can you take a look?

juliemr avatar Dec 09 '14 05:12 juliemr

One extra comment/improvement.

When the specs array is provided with wildcard like in example, the shard feature does not work (as I was expecting), because it takes items of array. The solution is to provide each file in separate. It would be easier to rebuild specs array to split wildcarded string into separate files.

specs: ['../tests/prse-splitted/*.e2e.js'] 
-> 
specs: [
    '../tests/prse-splitted/prse_1.e2e.js',
    '../tests/prse-splitted/prse_2.e2e.js',
    '../tests/prse-splitted/prse_3.e2e.js'
]

psech avatar Dec 09 '14 05:12 psech

With regard to your original issue it's two separate issues working together.

  1. you're providing browser-specific specs. The cli option will override the global spec only -- whether this is the correct behavior is up for discussion, but it is by design
  2. Also known, but perhaps more open to discussion is that, browser-specific specs will not dedup against global specs. I thought there was a reason for this, but I don't remember.

For your second comment, that should not be the case, I did notice that in your spec, you did not include a maxInstance. Can you try with

    maxSessions: 4, //optional

    multiCapabilities: [
        {
            shardTestFiles: true,
            browserName: 'chrome',
            maxInstances: 4,
            specs: ['../tests/prse-splitted/*.e2e.js']
        }
    ],

hankduan avatar Dec 09 '14 07:12 hankduan

Thanks for the quick response.

What I have been looking for is:

    // maxSessions: 4, //optional
    specs: ['../tests/prse-splitted/*.e2e.js'],
    multiCapabilities: [
      {
        shardTestFiles: true,
        browserName: 'chrome',
        maxInstances: 4
      }
    ],

In such approach I can provide all tests in config file and still manipulate with --specs cmd argument.

Thanks once again.

psech avatar Dec 09 '14 10:12 psech

Looks like the original issue is resolved. Before I close @juliemr Can you provide some input into whether the two points I raised should be the proper behavior.

hankduan avatar Dec 09 '14 17:12 hankduan

I think the behavior for 1 is good as-is.

for 2, I also don't remember if there's a reason for not de-duping, but I don't see a reason to change it arbitrarily. Closing!

juliemr avatar Dec 09 '14 18:12 juliemr