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

F!! Printable scenario - to better support BDD #460

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

emilybache
Copy link
Contributor

I've added a new library class PrintableScenario, with an example test of how to use it, and made a start on the documentation.

One of the methods has a checked exception which seemed to affect another test - I'm not sure what to do about that.

Look forward to discussing this proposed change with Llewellyn - we have booked a meeting to do so soon.

## Sample Code

I need some help with this part of the documentation. I'd like to include PrintableScenarioTest here as an example.
<!-- snippet: bdd_test -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you need is the following. These comments in the java file:

// begin-snippet: MySnippetName
public class PrintableScenarioTest
{
  @Test
  public void printBDDScenario() throws Exception
  {
    PrintableScenario story = new PrintableScenario("Buy Groceries", "Bob puts two items in the shopping cart");
    User currentUser = new User();
    ShoppingCart shoppingCart = new ShoppingCart(currentUser);
    story.given(new Printable<>(currentUser, UserPrinter::print),
        new Printable<>(shoppingCart, ShoppingCartPrinter::print));
    story.when("Add oranges to the cart", () -> {
      shoppingCart.add("Oranges", 1, BigDecimal.valueOf(5));
      return null;
    });
    story.when("Add apples to the cart", () -> {
      shoppingCart.add("Apples", 3, BigDecimal.valueOf(4));
      return null;
    });
    Approvals.verify(story.then());
  }
}
// end-snippet

and then you can reference it here in markdown with snippet: MySnippetName

@emilybache
Copy link
Contributor Author

I just updated this PR following conversation with Llewellyn. I think he probably wants to change a few more things too.

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

Successfully merging this pull request may close these issues.

3 participants