support for multiple Context and Do

Issue #2 new
created an issue

seems like subspec supports only single Context and Do.

it would be better if it could support multiple. from specflow:

Scenario: Multiple Givens

Given one thing

  And an other thing

  And yet an other thing

When I open my eyes

  And Listen

Then I see something

  But I don't see something else

could then be converted to subspec, using

"given one thing".Context(()=>...);

"And an other thing".Context(()=>...);

"And yet an other thing".Context(()=>...);

"When I open my eyes".Do(()=>...);

"And Listen".Do(()=>...);

"Then I see something".Assert(()=>..);

"But I don't see something else".Assert(()=> ...);

Comments (5)

  1. Johannes Rudolph repo owner

    Hi prabirshrestha,

    glad you're interested. I do not have particular plans for this feature, however I see this might generally be useful. However I would not want to overload the meaning of Context and Do, as there should be only one in each Specification. However, as far as I can guess, what you are suggesting is to have .Context() split up into multiple description/action pairs.

    What do you think about a syntax like this:

    "given one thing".Context(()=>...)
      .And("an other thing", ()=>...)
    "When I open my eyes".Do(()=>...)
     .And("listen..", ()=>...);
    "Then I see something".Assert(()=>..);
    "But I don't see something else".Assert(()=> ...);
  2. Adam Ralph

    This is an interesting proposal and actually very similar to some thoughts that I have been having.

    A few points I've found worth considering:-

    • I think I may be happy writing my multi-part Context like this, which is obviously already supported:-
    "given one thing" +
    "and another thing"
        .Context(() =>
            oneThing = ...;
            anotherThing = ...;
    • multiple Do? I'm really not sure about this. My approach has always been that a 3A's test should always have a single method call in the Action, and this is the aspect of the SUT we are interested in for this particular test even though the Assert may have multiple aspects. I propose that any method calls which come before this should be part of the Arrangement (Context), and any that come after it should be part of the Assert (Assert or Observation).
    • multiple Assert/Observation is obviously already supported
  3. Log in to comment