Open tamil777selvan opened 10 months ago
Hey @tamil777selvan, sorry for the late reply.
The support code loading for parallel is...a bit weird. We load it on the coordinator (from where we emit the messages about it) and then again on each worker (where the tests are actually going to be run). There's then a kind of sync process so they share the same ids in all places.
So if you jump in via the builder and add a hook on the coordinator only, there'll be a mismatch and thing will break in the way that you've seen.
I'm sure we can figure out a solution though. One of the things I've been looking at under the umbrella of Plugins is an extension point to prepend/append steps and hooks separate to the normal support code loading cycle. Also though, there might be other ways you can inject the behaviour you want besides a hook.
Can you say a bit more about the use case that's driving this?
Hi @davidjgoss,
This scenario is particularly relevant when integrating WebdriverIO with Cucumber's parallel execution mechanism. When parallel execution is enabled, the WebdriverIO hooks invoked are not processed within the parallel coordinator, resulting in the observed issue.
the WebdriverIO hooks invoked
Could you say a bit more about what these hooks do? i.e. is it user-authored code, or more like wdio plumbing? If you were to put them in a file and add it to the require
option, would that break in some way?
(I suspect there is some overlap with https://github.com/cucumber/cucumber-js/issues/2156 here.)
@davidjgoss, these codes are provided by users and are integrated into Cucumber hooks through the support code library within the wdio-cucumber-framework
. Even if we attempt to isolate this hook in a separate file and import it, it may not function as expected. The reason for this is that WebDriverIO hooks have their own names, and these names are internally mapped to corresponding Cucumber hooks.
For example, the beforeScenario
WebDriverIO hook aligns with the before
Cucumber hook.
This seems quite similar to the previous issue, as both cases involve the need to load custom hooks for parallel execution.
Thanks for the detail!
For this to work we have to find a way to have these user-authored hooks register on both the coordinator (parent) process and the worker processes.
I assume we don't have this problem for steps because users are calling the Cucumber Given
, When
, Then
functions directly and we're loading that code via the require
and/or import
options? Would this be an option for the hooks too (e.g. use Before
, BeforeAll
, BeforeStep
etc) or do the hooks get some special wdio-specific context/args passed to them?
👓 What did you see?
Hooks that are loaded via
supportCodeLibraryBuilder
encounter an error when using the parallel option in therunCucumber
API.✅ What did you expect to see?
Hooks loaded through
supportCodeLibraryBuilder
should be properly initialised and accessible, even when parallel mode is enabled.📦 Which tool/library version are you using?
Cucumber JS
- 9.5.1🔬 How could we reproduce it?
supportCodeLibraryBuilder
.BeforeAll
usingsupportCodeLibraryBuilder.methods.BeforeAll
.supportCodeLibraryBuilder
.Once you've completed the above setup, you can invoke
runCucumber
withparallel: 0
, and it should work as expected because it usesrunTime
.However, if you set
parallel: 1
, you will encounter the following error because it uses theparallel coordinator
.📚 Any additional context?
Code Snippet Used:
This text was originally generated from a template, then edited by hand. You can modify the template here.