Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Create a new namespace for each test scenario #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stusrob
Copy link

@stusrob stusrob commented Mar 3, 2019

This prevents leaking of local namespace variables from scenario to scenario when we are re-using the Tcl framework

This prevents leaking of local namespace variables from scenario to scenario when we are re-using the Tcl framework
Copy link

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This looks so neat, to a non-Tcl user!)

@@ -91,7 +91,7 @@ and in your step definition, you might have
Resetting state between scenarios
---------------------------------

Depending on how your test and/or application code is structured, there may be a chance of data persisting between scenarios, which could result in tests that pass or fail unexpectedly. To eliminiate the risk of this, Cucumber TCL will start a new TCL interpreter between every scenario by creating a new instance of the 'framework' object, meaning that the env.tcl file is loaded each time. Whilst this will remove the data leakage risk, it may also cause your scenarios to run slowly if there is a lot of setup required for a scenario to run (eg, setting up fixture data, building a database or loading large amounts of data into memory). To override the default behaviour of starting up a new interpreter, an environment variable can be passed into the 'cucumber' command enabling the sharing of the TCL interpreter via the 'framework' object:
Depending on how your test and/or application code is structured, there may be a chance of data persisting between scenarios, which could result in tests that pass or fail unexpectedly. To eliminate the risk of this, Cucumber TCL will start a new TCL interpreter between every scenario by creating a new instance of the 'framework' object, meaning that the env.tcl file is loaded each time. Whilst this will remove the data leakage risk, it may also cause your scenarios to run slowly if there is a lot of setup required for a scenario to run (eg, setting up fixture data, building a database or loading large amounts of data into memory). To override the default behaviour of starting up a new interpreter, an environment variable can be passed into the 'cucumber' command enabling the sharing of the TCL interpreter via the 'framework' object:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

@jowers
Copy link
Contributor

jowers commented Mar 4, 2019

@ahhbristow, is this somethin you could take a look at?

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

Successfully merging this pull request may close these issues.

3 participants