cucumber-js icon indicating copy to clipboard operation
cucumber-js copied to clipboard

access world parameters from setParallelCanAssign function

Open seddik-st opened this issue 2 years ago • 5 comments

Hello,

is there a way to pass those tags as world class parameters ?

const myTagRule = atMostOnePicklePerTag(["@tag1", "@tag2"]);

seddik-st avatar Jun 23 '22 09:06 seddik-st

Hi @seddik-st :)

I am not sure to understand your question

What would you like to do exactly? Would you have a more comprehensive example?

And without that in mind, what are you trying to achieve exactly? What is the issue you are facing that you try to workaround with your idea?

aurelien-reeves avatar Jun 23 '22 09:06 aurelien-reeves

Hi @aurelien-reeves,

Thank you for your quick reply.

We are trying to setup a CI profile that run many workers in parallel however we need to add a custom assign that prevent some sets of scenarios from running in parallel as showed in this tutorial.

It would be more elegant if we could pass those tags as world parameters in our CI profile (defined in the cucumber config file).

I hope it's clearer now :)

seddik-st avatar Jun 23 '22 09:06 seddik-st

I am not sure it is possible to pass those tags as world parameters. @davidjgoss do you confirm?

Regarding what you are trying to do, I am still puzzled:

  • the solution you found in the tutorial does not fit your needs?
  • why do you think it would be more elegant as world parameters?
  • if you use the cucumber config file, why don't you use simple tag expressions to select the scenarios you want to execute or not?

aurelien-reeves avatar Jun 23 '22 12:06 aurelien-reeves

So my understanding here is that we're talking about custom work assignment and specifically wanting to use the atMostOnePicklePerTag helper but without having the specific tags live in the support code, and be able to pass them through some config mechanism instead. This is unrelated to using tags to control which scenarios are executed, I think.

One thing we could do is add a third argument to the setParallelCanAssign consumer interface and give it the resolved configuration object - you could then pull world parameters from there.

Honestly though that feels a bit overwrought and for this case I would probably just advise to set an environment variable in your CI and then pick that up from your support code, like:

const myTagRule = atMostOnePicklePerTag(process.env.PARALLEL_ASSIGNMENT_TAGS.split(',');

davidjgoss avatar Jun 23 '22 12:06 davidjgoss

Hi @davidjgoss,

Thank you for your answer. We are aware of the alternative solution you already mentioned. However, we would like to have all cucumber config in one place and we thought that world parameters is the best place.

I agree with @aurelien-reeves to some degree, we can assign a special tag to each scenario that we want to prevent it from running in parallel (let's say @RunInSequence) However like this, we will have a lot of scenarios running under one worker which will slow down the execution time significantly. I'm not sure of the expected behavior please correct me if i'm wrong.

seddik-st avatar Jun 23 '22 15:06 seddik-st