Microservice Testing – What is Mocking Dependencies Called?

grailstestingunit testing

I've a RESTFul microservice written in Grails. This microservice has it's own DB. It also depends on two other microservices.

A typical workflow of the service is:

  1. Receives a GET request from a client e.g. browser
  2. Calls another microservice through http to get some information
  3. Queries it's own DB to get some data
  4. Send a response to the client

I want to write automated tests for this service. Whenever I'll run the test, it'll do the following:

  • Mock the external microservices
  • Create a database and populate it with test data
  • Run the application and configure it to use the mock services and DB
  • Run the test cases by sending http requests and matching responses

My question is: What type of test is this?

I'm not a QA so may be I'm asking a stupid question.

Best Answer

Testing terminology is very messy. Usually I've seen this type of tests to be called "integration tests", but to me it seems to be too overloaded term used also for quite different type of tests.

So I call them component tests. Your microservice is one component of the larger system. Term is quite self-explanatory and fits well definition from Martin Fowler:

A component test is a test that limits the scope of the exercised software to a portion of the system under test. It is in contrast to a BroadStackTest that's intended to exercise as much of the system as is reasonable.

Related Topic