StoryData
StoryData is a plain old C# object (POCO) of your choice. An instance of this class will be instantiated at the beginning of your test arrangement and is accessible in every story. This means you can enrich your StoryData as your stories progress.
You can only have one instance of StoryData per configured scenario.
Story Data flow
The story data can be accessed from within a story from the scenario context.
The example below demonstrates accessing the story data to get the correct id to use in the URL and updating the story data with the result of the API call.
1
public DepositMade Deposit_has_been_made(Deposit depositRequest)
2
{
3
return
4
When(context =>
5
{
6
var response = context.Api.Post(quot;api/bankaccounts/{context.StoryData?.BankAccountId}/deposits",
7
depositRequest);
8
9
response.ShouldBe.Ok();
10
11
context.StoryData.DepositAmount = depositRequest.Amount;
12
})
13
.ProceedToChapter<DepositMade>();
14
}
Copied!
Last modified 1yr ago
Export as PDF
Copy link