Skip to content

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

Closed
emilybache wants to merge 9 commits intomasterfrom
printable_scenario
Closed

F!! Printable scenario - to better support BDD#460
emilybache wants to merge 9 commits intomasterfrom
printable_scenario

Conversation

@emilybache
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@ScottBob
Copy link
Copy Markdown
Contributor

I'm not sure this is still worth doing in today's AI-driven world. If that proves to be wrong, we will reopen the issue.

Llewellyn
Jay
Scott

@ScottBob ScottBob closed this Mar 12, 2026
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.

4 participants