This blog post is in response to Challenge 7 of the #GivenWhenThenWithStyle blog post series with Gojko Adzic
You can see what the challenge is here:
https://specflow.org/blog/how-to-deal-with-external-data-formats-givenwhenthenwithstyle/
Having the message format in the test would (as mentioned in the challenge) look terrible and would be difficult to understand.
If I was to rewrite this scenario I would do something like the following:
1) Write a test that tests the validity of the payment message. So something like
Scenario : payment message validity
Given an account EE382200221020145685 has a balance
When the system receives a payment message
Then the payment message is valid.
I would store the actual payment message in another file as not to clutter the scenario file and this message would be passed into the test in the When
line. The Then part of the test could cover various areas, such as:
- All the correct tags are present
- The xml is valid
2) I would then add another test to make sure that the payment status report is valid:
Given an account EE382200221020145685 has a balance
When the system receives the payment message
Then the payment report status is valid.
3) I would then move onto testing the actual content of the message. I would speak to the business users and ask them what fields they really care about in the message and use them in my tests. So I would do something like this:
Scenario: Transactions in payments
Given an account EE382200221020145685 has balance of 100.00 EUR
When the system receives the payment message with the following initiating party values
| MsgID | CreditDateTime | Payment| InitiatingPArty|
| MSGID000002| 2020-07-28T10:33:56| 22.00 | Tom Nook |
And the payment message has the following Payment information
| PaymentMethod| PaymentAmount|Payment Date| AccountIBAN | FinancialINstitutionIDBIC| AccoumtIBAN |
| TRF | 22.00 |2020-07-28 | AT611904300234573201 | ABAGATWWXXX | EE382200221020145685|
Then the following values are returned in the payment report status
|MsgID |CreditDateTime | OriginalMessageID|
| STAT20200728103356001 | 2020-07-28T10:33:56 | MSGID000002 |
Writing the tests in the above way will enable more tests to be written by expanding the test to use Examples. Also If the message is an industry standard one the business users will probably know what they look like off of the top of their head. So the value of the tests is to make sure that the content in important fields is correct not all of the fields in the messages. It also abstracts the message away from the tests in order to make them easier to read and focus the tests on whats important. The message can still be viewed as it would be stored in a file somewhere and a business users if they want could have a look at the file in which the message resides.
Comments
Post a Comment