I am trying to leverage Karate (https://github.com/intuit/karate) as a key component in an overall testing strategy for testing containerized, cloud-based microservices. Assuming that both the microservice under test and Karate have their own containers, the process is as follows:
- Fetch each container for local deployment
- Build (via gradle) the components in the Karate container (assume there are Java classes required by our mocks)
- Deploy (via gradle) the mocks and get them running in standalone mode
- Inject information about the mocks into the YAMLs of the microservice
- Build and deploy the microservice locally
- Run Karate tests (passing information about the mocks and/or environment) via CLI
My first question is whether or not this is a Good Idea(TM) or a Bad Idea(TM). On the surface it seems both reasonable and achievable but I am wondering if I am trying to use Karate in a way that it was never meant to be used. I toyed with the idea of keeping all the Karate stuff (including the mock sever) in the tests themselves, but then steps #3-5 would have to inject the mock information into the microservice, then run commands to get the microservice built and deployed all within test suite, which seemed to me like a Bad Idea(TM). Better instead to do this as part of a pipeline in a Jenkins job right?
My second question is how to best export mocks, files and Java dependencies for outside use (to support step numbers 2-3), for example here is the file structure:
.
+-- build.gradle
+-- src
| +-- main
| +-- java
| +-- JWTSigner
| +-- PEMHelper
| +-- resources
| +-- private-key.pem
| +-- public-key.pem
+-- test
| +-- main
| +-- java
| +-- api
| +-- cats
| +-- cats.feature
| +-- dogs
| +-- dogs.feature
| +-- AllTestsRunner.java
| +-- mocks
| +-- mock-auth.feature
| +-- templates
| +-- public-key.json
| +-- resources
| +-- lolcats.pdf
| +-- loldawg.jpg
So here, mock-auth.feature
needs the stuff in src/main
as well as in src/test/templates
. I've been able to play around with gradle tasks and copy the stuff required into a subdirectory of a main directory with the standalone Karate JAR to so the mock can be started, but I was wondering if there's a better way...
Any feedback is appreciated, but if negative, please suggest an alternative for me to attempt. Thank you.