Search code examples
javaspring-bootkaratespring-boot-test

How to pass token generated by java code in karate test case?


2 types of test cases I have written:

  1. Using spring boot
  2. Karate framework

enter image description here

To access the endpoints, valid token is required and I am generating the token using spring bootenter image description here test. I want to use the same token for karate framework but not sure how to pass it as a parameter so that I will use it in my feature file. We are using client-credentials for auth.enter image description here I want to pass token in below mentioned karate test case:

enter image description here


Solution

  • Our team was using the java code to generate the JWT token so I just called that java method in my karate test case and it worked.

    Note: We have an option to call java method in our karate test case. I was not aware about it.