You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TearDown method not being invoked after exception thrown in Then step #243
publicMofiAnalysesPhrase():base("Mofichan analyses a phrase given to her"){varcommand=default(string);vartags=default(IEnumerable<string>);this.Given(s =>s.Given_Mofichan_is_configured_with_behaviour("analysis")).And(s =>s.Given_Mofichan_is_running()).When(s =>s.When_Mofichan_receives_a_message(this.JohnSmithUser,command)).And(s =>s.When_behaviours_are_driven_by__pulseCount__pulses(2)).Then(s =>s.Then_Mofichan_should_have_responded_with_expected_analysis(tags)).WithExamples(newExampleTable("command","tags"){{"Mofi, perform analysis \"hello Mofi\"",new[]{"directedAtMofichan","greeting"}},{"Mofi, perform analysis: \"how are you doing?\"",new[]{"wellbeing"}},{"Mofi, analyse: \"you're the best!\"",new[]{"positive"}},{"Mofi, analyse phrase: \"you're the worst!\"",new[]{"negative"}},{"Mofi, analyse phrase: \"That's right Mofi\"",new[]{"directedAtMofichan","affirmation"}},{"Mofi, analyse phrase: \"That's correct Mofi\"",new[]{"directedAtMofichan","affirmation"}},{"Mofi, analyse phrase: \"That's wrong Mofi\"",new[]{"directedAtMofichan","refutation"}},{"Mofi, analyse phrase: \"That's incorrect Mofichan\"",new[]{"directedAtMofichan","refutation"}},}).TearDownWith(s =>s.TearDown());}
This BDDfy test is configured to run for a set of example data. Currently, some of these examples pass and some fail.
Up until the first failure, the tests work as expected - the given, when and then steps are performed in order, followed by the teardown using TearDown(). However, as soon as the first test failure occurs (signified by an exception being raised within Then_Mofichan_should_have_responded_with_expected_analysis), the teardown method stops being invoked, meaning that all following tests fail due to the test context not being "clean" as opposed to the actual code under test being wrong. By stepping through the code using a debugger, I can see that as soon as an exception is thrown within the Then step, the test runner invokes the Given_Mofichan_is_configured_with_behaviour without going through TearDown first.
I get the following output when running these tests:
Activity
SonOfSardaar commentedon Jun 1, 2026
This is fixed, look at tests in #302