Skip to content

A test class instance is created for each step

Michael W Powell edited this page Dec 8, 2020 · 1 revision

This issue affects 1.x versions only. It does not affect versions 2.x and above.

Note that we mention it here for historial xBehave.net reasons only, since xWellBehaved.net derived from the root project well after this was resolved.

In xBehave.net version 1.x, an instance of the test class (if it is not static) is created once before the scenario is executed and all the steps are executed in the context of that instance.

The xUnit.net runner also creates an instance of the test class before each step is executed. These per-step instances are not used for anything and are superfluous.

However, if the construction of your test class induces static side effects, you may experience issues. The recommendation is to use Backgrounds to create common contexts for your scenarios instead of test class constructors (see also: An instance of the test class is created for every step).

Thanks to George Hemmings for spotting this issue.

Clone this wiki locally