I am very new to BDD, and having a bit of trouble outlining the scenarios for some code that I wrote. The code basically queries a Couchbase bucket for abandoned orders, and then calls a cancel order API to cancel those orders. For each call to the cancel order API, it calls another service to generate access token.
The entire code has been written in RxJava. In case of errors, I have fallback observables in place (for example, should anything go awry while querying Couchbase, it fallbacks to an empty observable). I have similar fallbacks in other places in the code as well.
I want to write Cucumber scenarios for my code. But I can't figure out how to go about it. For example, should I assume that the service has a valid access token and an orderId to cancel (querying CB returns a bunch of orderIds that need to be passed on to the cancel order API along with an access token)?
Ideally, I should be testing the following:
-
Querying Couchbase fails. In this case, I should get an empty observable.
-
Call to the access token API fails. In this case as well, I should get an empty observable.
-
Call to the cancel order API fails. In this case as well, I should get an empty observable.
-
Call to cancel order API returns some response code other than 200. Then assert on the response codes.
-
The happy case.
Now suppose I want to test the first case, that is, querying CB fails. What will be the background in this case? How should I simulate a query failure?
Aucun commentaire:
Enregistrer un commentaire