Writing Cucumber scenarios for reactive code
up vote
1
down vote
favorite
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?
unit-testing testing cucumber rx-java project-reactor
add a comment |
up vote
1
down vote
favorite
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?
unit-testing testing cucumber rx-java project-reactor
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
unit-testing testing cucumber rx-java project-reactor
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?
unit-testing testing cucumber rx-java project-reactor
unit-testing testing cucumber rx-java project-reactor
asked Nov 11 at 10:23
Prashant Pandey
18112
18112
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04
add a comment |
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247796%2fwriting-cucumber-scenarios-for-reactive-code%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think you are planning your tests on the wrong level. Cucumber should be used for testing the domain level of your application in such a manner that a business analyst can understand your tests. At best, the tests should be technology agnostic, i.e. they should not need to know about the underlying tech stack, which in this case is RxJava. The cases you describe are more or less error cases and IMO unit tests are best suited for these scenarios. Use Cucumber to test "one level higher" i.e. the components that use these Observables returning data. Use mocks to setup the appropriate start data
– kaskelotti
Nov 14 at 19:04