Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Document TestStep.execute(world, ...) #9

Open
aslakhellesoy opened this issue Feb 9, 2016 · 0 comments
Open

Document TestStep.execute(world, ...) #9

aslakhellesoy opened this issue Feb 9, 2016 · 0 comments

Comments

@aslakhellesoy
Copy link
Contributor

For the time being I'll document it here. When someone is happy with that documentation we can lift it out into the code.

The world argument is the this object - the object in which the step definition method will execute.

The intention is to avoid leaking state between scenarios. Each scenario creates new objects for each scenario, and invokes step definition methods or closures in the context of one of those objects.

Whether to create a single world object or several ones will depend on the programming language.

For JavaScript - a single object would be sufficient, since Function.apply allows executing any function with an arbitrary this object. (Unless the function is anonymous using the () => {} syntax, but that's a different issue).

For Java however, we'll use Method.invoke, which requires the object to be an instance of the class where the method is defined. So we'll need an object for each class hosting stepdef methods.

For Python I believe func.__call__ will be used, and the first argument will be a thisArg object similar to JavaScript that can be shared across stepdef functions in several files.

Maybe it's better to name the object thisObject?

Is this clearer now? (ref cucumber/common#8 (comment))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant