Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>TestInitialize</code> is not called because it is inside your Steps class and not inside in an Unit Tests (because the actual unit test is inside the <code>.cs</code> which is generated from your <code>.feature</code> file).</p> <p>SpecFlow has it's own test-lifetime events which are called hooks, these are all the predefined hooks:</p> <ul> <li><code>[BeforeTestRun]</code> / <code>[AfterTestRun]</code></li> <li><code>[BeforeFeature]</code> / <code>[AfterFeature]</code></li> <li><code>[BeforeScenario]</code> / <code>[AfterScenario]</code></li> <li><code>[BeforeScenarioBlock]</code> / <code>[AfterScenarioBlock]</code></li> <li><code>[BeforeStep]</code> / <code>[AfterStep]</code></li> </ul> <p>Note that this allows for greater flexibility in setup. For additional information <a href="https://github.com/techtalk/SpecFlow/wiki/Hooks" rel="nofollow">see the documentation</a>. </p> <p>Based on the fact that you want to use the <code>TestFixtureSetUp</code> attribute you will probably need the <code>BeforeFeature</code> hook which will be called once before each feature, so you need to write:</p> <pre><code>[Binding] public class UsersCRUDSteps { [BeforeFeature] public static void TestInitialize() { ObjectFactory.Initialize(x =&gt; { x.For&lt;IDateTimeService&gt;().Use&lt;DateTimeService&gt;(); }); throw new Exception("BBB"); } //... } </code></pre> <p>Note that the <code>[BeforeFeature]</code> attribute needs a <code>static</code> method.</p> <p>You should also note that if you are using the VS integration there is an project item type called <code>SpecFlow Hooks (event bindings)</code> which creates a binding class with some predefined hooks to help you get started.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload