Verify could definitely be written to not skip steps after the first
failing step.
I thought about allowing an option that could let you continue to
execute steps even if one failed, but I couldn't think of why I'd want
to do that.
Could you describe why you think it would be useful?
Also, all steps are treated equally. There's really no difference
between a given, when, or then except for the label. If you only
wanted it to continue when a then step failed, we'd have to check the
step type, but that wouldn't be difficult.
Thanks.
--
Jason
I just checked in a new property that allows this. If you have
Subversion access and want to check the code out, you can give it a
spin. Otherwise, I'll put together another release either today or
tomorrow.
I called the property ContinueAfterFailedSteps. It's a little wordy so
if you have a better suggestion, I'd love to hear it. It defaults to
false, by default. To get the behavior you want, you could just set it
to true before calling any of the Verify methods.
--
Jason
Thanks for the feedback.
I didn't add an overload to Verify because then I would also have to
add overloads for the VerifyText, VerifyFile, and
VerifyEmbeddedResource methods. All of these call Verify internally.
In my actual work where I'm using BehaveN, I tend to use VerifyText or
VerifyEmbeddedResource more than feeding the steps one at a time with
Given, When, and Then, and then invoking Verify.
As far as the output goes, I agree that the duplication of the error
message is a little bothersome. As is the stack trace for the BehaveN
code. I'll look to see if it's possible to do something to filter out
the part of the stack trace you don't care about, but I'm not sure it
will be possible.
I just realized something regarding the new property. If turned on,
this means that Verify will never throw an exception. This will make
it look like everything passed. I'll have to do something at the end
of Verify to throw an exception if any exceptions were caught while
executing the steps.
--
Jason
Given a new calculator
When adding the numbers 1 and 2
! Then the result should be 1
TestCase 'CalculatorScenarios2.AddingTwoNumbers' failed:
BehaveN.VerificationException :
Expected: 1
But was: 3
C:\code\behaven\BehaveN.Tests\CalcTests.cs(54,0): at
CalculatorScenarios2.the_result_should_be(Int32 result)
Given a new calculator
When adding the numbers 1 and 2
! Then the result should be2 2
TestCase 'CalculatorScenarios2.AddingTwoNumbers2' failed:
BehaveN.VerificationException :
Expected: 2
But was: 3
C:\code\behaven\BehaveN.Tests\CalcTests.cs(59,0): at
CalculatorScenarios2.TheResultShouldBe2(Int32 result)
0 passed, 2 failed, 0 skipped, took 0.81 seconds (NUnit 2.5).
--
Jason
------ Test started: Assembly: BehaveN.Tests.dll ------
Given a new calculator
When adding the numbers 1 and 2
! Then the result should be 4
! And the result should be 5
TestCase 'BehaveN.Tests.CalculatorScenarios2.AddingTwoNumbers'
failed: BehaveN.VerificationException :
Expected: 4
But was: 3
C:\code\behaven\BehaveN.Tests\CalculatorTests.cs(72,0): at
BehaveN.Tests.CalculatorScenarios2.the_result_should_be(Int32 result)
0 passed, 1 failed, 0 skipped, took 0.81 seconds (NUnit 2.5).
Notice how it's only outputting the first exception. You can still see
that both steps failed because of the ! symbols in front of them.
It might be possible to combine all of the exception messages and
stack traces into one exception. I might try doing that tomorrow.
--
Jason