mardi 19 novembre 2019

How to test data gathering service?

I'm working on a HTTP server. The server's responsibility is to take requests, process them and save the data into a database. There is no visible output. Then there is some other service, lets call it the processing service, that reads the data and does something with it. This service can return some data to a user.

Now I want to write tests for the gathering data service. Ideally tests should be code independent so I thought about simply calling the service with HTTP requests. But as I said, there's no output and the problem is how to validate results? Here are my thougths:

  1. I could simply connect to the test database, read data from there and validate it. But this makes the database choice a hard dependency. We already want to change our database, that would force us to modify tests as well.
  2. I could additionally use the processing service and utilize it to read the data back. This is an option, although requires lots of effort. The processing service is mantained by another team.
  3. I could implement test API in the gathering service itself. This is sort of ok, but then keeping an API only for test purposes sounds ugly to me. Although, to be honest, I find that solution to be the best under these circumstances.

Are there any other ideas?

Aucun commentaire:

Enregistrer un commentaire