-
Notifications
You must be signed in to change notification settings - Fork 74
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
emilybache
wants to merge
9
commits into
master
Choose a base branch
from
printable_scenario
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LarsEckart
reviewed
Jan 11, 2024
## 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 --> |
There was a problem hiding this comment.
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.