Search code examples
javamavenjenkinsjunitkarate

How to run a KarateTest.Jar?


I have created a jar file comprising all Karate test cases of my project, now how do run it? i was able to run the tests in eclipse using Junit now i'm trying to integrate karate tests in Jenkins CI pipeline jobs and am not sure how to do this.

I checked if the jar had the test cases of the project and it did.

 root@mymachine:# unzip -v api-tests.jar

  Archive:  api-tests.jar

Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----

    0  Stored        0   0% 04-08-2019 05:43 00000000  META-INF/

   389  Defl:N      226  42% 04-08-2019 05:43 131755ce  META-INF/MANIFEST.MF

    0  Stored        0   0% 04-08-2019 05:43 00000000  examples/

   747  Defl:N      445  40% 04-08-2019 05:43 8adc3e2f  examples/ExeTest.class

Ran the below command to execute the Test Jar. Running the command in the test jar's directory.

root@mymachine # java -cp api-tests.jar:/usr/share/java/junit4.jar junit.textui.TestRunner com.cape.board.api.examples.ExeTest


Class not found "com.cape.board.api.examples.ExeTest"

So how do i execute this and is there anyother way to integrate Karate in Jenkins pipeline job.


Solution

  • You specify class in cmd is com.cape.board.api.examples.ExeTest, but you packaged the class into api-tests.jar is examples/ExeTest.class. That's why report class not found.