3

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.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
Sarah Kazi
  • 71
  • 6
  • 1
    Karate can definitely do this. We tend to use a Wiremock standalone instance to stub in for any downstream service and record the requests that the SUT sends it. We write our Karate tests so that they hit the SUT, then verify that the SUT made the expected call to the downstream "service" (Wiremock) by calling it's __admin/requests endpoint to see what it was sent. This is cheaper than testing with everything running and gives more visibility into whether the SUT is adhering to interface contracts. A tool like docker-compose can spin everything up and down for testing cheaply too. – Scott Shipp Dec 31 '20 at 21:33

3 Answers3

1

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.

pavelsaman
  • 7,399
  • 1
  • 14
  • 32
Nicolas C
  • 11
  • 1
  • actually you can write glue code for anything and even call CLI-s: https://twitter.com/KarateDSL/status/1128170638223364097 | https://stackoverflow.com/a/62911366/143475 – Peter Thomas Dec 30 '20 at 08:59
1

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
sdaas
  • 174
  • 1
  • 5
0

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.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248