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

Feature request: autogrouping scenario steps #6

Closed
imrekoszo opened this Issue May 15, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@imrekoszo

imrekoszo commented May 15, 2015

At present I am aware of 2 ways of running scenarios:

1

Runner.RunScenario(
    Given_a_customer,
    And_a_product,
    When_the_customer_selects_the_product,
    Then_foo,
    Then_bar);
  • Good: most method names state whether they are arrange, act or assert making reuse unambiguous
  • Bad: And_a_product() is ambiguous (could belong to G W or T)
  • Bad: Then_foo and Then_bar will be printed in the report as "Then foo Then bar" instead of "Then foo And bar" which would read better

2

Runner.RunScenario(
    given => a_customer(),
    and => a_product(),
    when => the_customer_selects_the_product(),
    then => foo(),
    and => bar());
  • Good: whole scenario prints in a nice to read way
  • Bad: all methods become simple statements with no indication whether they are arrange act or assert making reuse hard (I've seen tests where the author mistakenly reused an arrange method as an assertion because of this)

Suggestion

Add an optional feature that formats steps in a way that if the first word of the current step equals the first word of the previous step, the first word of the current step will be replaced with And. This would result in a nicely readable output and unambiguous method names.

Example:

Runner.RunScenario(
    Given_a_customer,
    Given_a_product,
    When_the_customer_navigates_to_the_site,
    When_the_customer_selects_the_product,
    Then_foo,
    Then_bar);

would be formatted similarly to:

Given a customer
And a product
When the customer navigates to the site
And the customer selects the product
Then foo
And bar

Optional extras:

  • configure case sensitivity for the comparison
  • configure the number of leading words to compare and replace
  • configure the replacement phrase ("And", "And also" etc.)
@Suremaker

This comment has been minimized.

Collaborator

Suremaker commented Jun 1, 2015

The next version of LightBDD would contain this change.
It would be released soon.

@Suremaker

This comment has been minimized.

Collaborator

Suremaker commented Jun 21, 2015

Done in version 1.7.0.0

@Suremaker Suremaker closed this Jun 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment