I am a bit confused when preparing a test case with BDD.
Here is my desired requirement expressed with Gherkin Syntax.
Given A user is subscribed to the system
When A user try to subscribe again
Then System should send him a notification "Subscription unsuccessful"
and Admin Portal User should view related KYC Fields as blank
How should internal system interaction be reflected in BDD ?
For example:
a) After each step, persistence is needed in MongoDB
b) A few internal API calls need to be invoked as pre-validation before the KYC API call
c) Notification needs to be send to the user after the process ends
Should notification be considered as system behavior or business behavior?
How should persistence, calling an API, etc. be reflected in BDD ?
Am I missing something?
Can anybody help?
A notification being a system behavior or business behavior is largely dependent upon the system under test.
If the whole point of the scenario is to ensure a notification is sent, it is a business behavior. Basically it is all about your Then
.
Since your scenario is asserting the notification has been sent, I would classify it as a business behavior, and your scenario is perfectly valid.
A BDD test does not necessarily need a user interface. It can involve calling APIs directly and making assertions on their results. I've even written unit tests for a single method on a class using Gherkin. It just happens to state in business terms what that method is doing. This is precisely what BDD was designed for.