-
-
Notifications
You must be signed in to change notification settings - Fork 46
Analyzer warning for code outside step delegates #406
Comments
We typically initialize some values at the beginning of a scenario (outside of a step). And I think that is okay because this code really should not fail. If it does, the whole scenario fails, which is okay with my understanding. Btw |
Why not put that in a step? It can even go into a background step if you want to reuse across scenarios.
Why does it have to be a "dummy" step? If you are writing a step anyway, I'd give it a proper sentence: "And I get the last answer"
.x(() => answer = calculator.GetLastAnswer()); |
I agree with initiatlisation in a step - that's how I interpret 'Given' steps. However, I find it a bit ugly for test variables to be declared as method parameters - particularly when the test also has parameters that I'm driving using |
@ma499 that's a fair point. I guess it's a matter of taste. I guess such an analyzer could attempt ignore variable declarations, but it's always the edge cases that trip up those kind of things. |
Will be made redundant by #362. |
The basic premise of xbehave is that everything should be inside step delegates so that success or failure of a given scenario always related to a specific logical step, identified by a natural language sentence. If code is outside a step delegate, then this benefit is lost.
Slightly contrived example:
If one of the two commented operations throw, it's not possible to tell any more from the natural language output which one of them threw. It is necessary to resort to inspecting the call stack, which is the case when not using xbehave. Thus, the main benefit of xbehave is lost.
The text was updated successfully, but these errors were encountered: