Can I use karate for testing microservices?

Viewed 887

Let me give some background. We're trying to do e2e testing between a bunch of spring boot services that write to kafka, move files and talk to other services to do the file moving. I think we're pretty good on integration testing with mocks and whatnot, but is there a way to leverage karate or any other testing framework to help achieve fully e2e for the few major scenarios? Like can i have a test on one service that takes actual data and sends to the next service without mocking?

I hope that made sense. Thank you.

3 Answers

As you said, karate is for e2e testing. The answer is quite easy: if you can assess changes in your overall state across all microservices according to the result of some action(s), then yes.

Of course all these changes, actions and assessments have to be HTTP, since it is Karate’s main protocol.

It really does not matter whether the "system under test" is a single service or a collection of services - we just need to think in terms of input to the system, and the outputs from the system. From the description it looks like, the "system under test" does ...

(a) interact with some downstream services : you should be able to mock them using Karate (b) produces to Kafka : See if https://github.com/Sdaas/karate-kafka can help here (c) does some file i/o

For the last one, you may need to write some custom Java code that can be called from within Karate. See https://github.com/Sdaas/karate-kafka/tree/master/src/test/java/karate/java for some examples.

The answer is yes. Even within the same Scenario you can make calls to 2 different URL-s. So for example you can GET from service A and use the response to POST to service B.

Related