Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fluent chaining of the current context of the test #270

Open
bronumski opened this issue Feb 20, 2019 · 0 comments
Open

Support fluent chaining of the current context of the test #270

bronumski opened this issue Feb 20, 2019 · 0 comments

Comments

@bronumski
Copy link

bronumski commented Feb 20, 2019

I love the fluent API , in fact that is all I really use. I do a lot of testing using fluent methods and it would be nice to be able to pass the current context of where you are in the test sequence into the next step instead of having to hold onto local variables.

Example using pseudo selenium pages:

class Page1 {
  public Page1 DoSomething() { returns this; }
  public Page2 GoToPage2() { returns new Page2(); }
}
class Page2 { public Page2 DoSomethingElse() { returns this; } }

[Scenario]
public void DoSomeComplexFlow() => Site.NavigateToPage<Page1>()
  .Given(page1 => page1.DoSomething(), "Given we do something on page 1")
  .And(page1 => page1.GoToPage2()), "And we have gone to page 2")
  .When(page2 => page2.DoSomethingElse(), "When doing something else")
  .Then(page2 => page2.GetType() == typeof(Page2), "Then we have a context of Page2")
  .BDDfy();

This allows a nice flow of the scenario.

On a side note, I don't always use the template syntax that I have done above but when I do it would be nice not to have to prefix everything with Given, When, Then or And.

Anyway that, for me, would be an awesome addition to an already awesome API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant