cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.05k stars 1.09k forks source link

Improve execution time by executing on multiple machines #2303

Open MiladSadinam opened 1 year ago

MiladSadinam commented 1 year ago

🤔 What's the problem you're trying to solve?

We love cucumber and use it for end-to-end testing our UI. As the tests include the UI, backend and database, they are quite "heavy" and are taking more and more time. We would like to decrease the execution time, especially as they are used in our pull-request CI/CD.

✨ What's your proposed solution?

Another quick way to speed up tests is to split them across multiple machines. I believe Cucumber-Js currently does not support this, correct? Or is there any third-party package I did not find?

We would love that feature. Nowadays, hardware is getting more cheap, and you can so easily speed up the workflow by paying little more money.

⛏ Have you considered any alternatives or workarounds?

Cucumber-js supports the parallel parameter, but our pull-request provider (Atlassian Bitbucket) only supports a limited number of (not very strong) machines, so we currently cannot go beyond 2 for the parallel parameter.

davidjgoss commented 1 year ago

@MiladSadinam thanks for raising, you'r right that it's currently not supported. parallel just uses multiple worker threads but on the same machine which for reasons you've noted has limitations.

From what you've written, I think the kind of thing you're looking for is more like Playwright's sharding feature, where an independent run would execute a subset of test cases based on an index and count, e.g.:

# machine 1
npx cucumber-js --shard 1/3

# machine 2
npx cucumber-js --shard 2/3

# machine 3
npx cucumber-js --shard 3/3

I'd definitely be supportive of doing this as a relatively low-effort way to give people another lever for performance.


Some thoughts about how this should work (more for internal audience):

MiladSadinam commented 1 year ago

Thank you for your feedback. Yes, the sharding feature would exactly be what I would like. As feedback from our side, we would not care about merging of the reports.

I was wondering how I could achieve a similar result until you guys hopefully implement this. My idea would be something like:

# machine 1
cucumber-js --name "^[a-m].*$"

#machine 2
cucumber-js --name "^[n-z].*$"

I would need to tweak the limit between the two machines, to get similar execution times, but otherwise it should work.

davidjgoss commented 1 year ago

Yep, that might be worth a try.

davidjgoss commented 1 year ago

Just noting we could also explore doing this as a plugin, with the new plugins concept.