2

I am setting up the integration test framework for a Java rest api in our project and we want to run integration test in the gitlab pipeline. Since these tests are running in the same project as the API, we are wondering couple of things:

  1. We dont want to run Karate tests during the maven build process. We want to run them only at integration test stage after the application deployment stage is complete. How do we do that as the maven build process runs both the junit unit tests and karate tests.
  2. Since the API requires authentication, we need to run the karate test in a docker container, since we can inject our credentials only in the container as we are using hashi-corp vault to store the credentials. How do we launch a container with Karate client.

1 Answers1

0
  1. There are ways to run only a subset using Maven. What I do is define a different JUnit test, and call that from the command-line. Read the docs for more: https://github.com/karatelabs/karate#command-line

  2. As long as you can pass environment variables (which you certainly can in Docker) you are good. Refer: https://stackoverflow.com/a/52821230/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi Peter, thank you so much for responding back to my question. I was able to figure out the first part of segregating my integration tests with unit tests. However, the second part is something I am trying to still figure out. To make it crisp, I need to package the karate integration tests in a spring boot jar and then run the spring application in a docker container. Below link shared by you in a different thread doesnt work anymore. https://github.com/ali-nutmeg/broken-karate I am looking at the example shared in the below link https://github.com/celcius112/karate-spring Any suggestion pls – ContinuousLearner Feb 17 '22 at 16:04
  • @ContinuousLearner I'm going to pass on this question. I have nothing more to add to my answer - maybe someone else can help, also search stack overflow for https://stackoverflow.com/search?q=%5Bkarate%5D+boot – Peter Thomas Feb 17 '22 at 17:11