1

I'm involved in a microservices based application. I'm trying to apply the BDD process for this. I need a recommendation how to apply this process correctly given this type of architecture. It is recommended to avoid or keep at minimal level the end-to-end tests that span across many microservices. I agree with that.

From my point of view, staying away from end-to-end tests means that we don't have executable specifications (one of the bdd benefits) for the use cases that span multiple services. Instead we have only service level specs. Is my understanding correct?

Here is an example. Say, I have a e-commerce system and I need to implement the feature:

  Adding a product to the shopping cart.

When discussing this with the client, we put down the following scenario:

Given I'm logged in
  And I search for the book "BDD in Action"
  And I identified the required book
When I add the item to the shopping cart
Then I see the item added to my shopping cart

This use case spans the following microservices: Security, Product Catalog, Shopping Cart.

Hence the question - how do I implement the above shopping cart feature following the BDD process?

  • Should I automate the above feature file? According to the already mentioned recommendation, I should avoid end-to-end tests spanning multiple microservices. Does it mean that the above story remains not executable?
  • Should I go straight to the Shopping Cart Service and write a specification for it, avoiding the unnecessary Givens from the above story?

    When I add an item to the Shopping Cart Then I see the item added to my shopping cart

0

The beauty of BDD is that it doesn't care how you construct your application, only that the required features work. BDD is intended to test the application implements all the requirements correctly, not to test each individual component of your application.

It's for this reason that we need different levels of testing in our projects. To test each microservice in isolation, you'll need unit tests.

To answer your specific questions:

  • Should I automate the above feature file? Yes It's a requirement
  • The above recommendation seems ill-informed based on what BDD is supposed to provide, so it should be executable.
  • Going straight to the shopping cart service is more of a unit test. You should definitely have that unit test.

Microservices do come with the added cost of complexity. The architectural pattern pretty much mandates you have a good DevOps pipeline to automatically deploy an instance of your application and run your BDD tests against it.

My personal recommendations are:

  • Automate the deployment
  • Allow BDD to do its job and validate application functionality
  • Use Unit Tests to validate specific microservice behavior, as well as internal behavior of the support classes.
  • Unit Tests should run as part of the build, with the build failing if the tests don't pass
  • BDD should run in the DevOps environment after the deployment is complete
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.