Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create tests jar with all the Karate dependencies [duplicate]

I have the following project structure.

  • src/test/java

There is no src/main folder.

Above src/test/java folder contains some scala classes as well as some java classes. When i build the jar file using following plugins

  • maven-jar-plugin : it generates the tests jar file but dependencies are not included in that jar file
  • maven-shade-plugin : this plugin generates the jar file without tests suffix and include all the dependencies in the generated jar.

Please suggest

how to generate the 'tests' jar with all the dependencies in it unpacked. OR How to generate jar file in this case with all the classes under src/test/java folder and all the dependencies required by the tests classes

like image 418
user3531900 Avatar asked Nov 06 '22 20:11

user3531900


1 Answers

Yep, code being under src/test/java is typical for a Karate test. You can't put under src/test/main unless you wired things up to run the tests , perhaps by hitting a spring boot controller to start them. Then, in your Docker container, you can start the tests from your runnning spring boot app. That is very non-standard and I wouldn't recommend doing that.

Instead, I would just start with a Maven docker image, and build your own image that knows how to copy the test files (un-jarred) into the image, THEN you wont need to .jar it all up. I made an example here (https://github.com/djangofan/karate-test-prime-example), complete with proper handling of the docker exit-code.

There is some documentation on the Karate site for making a standalone karate-jar but the documentation on the specifics of how to do that is sparse. I bet it works if you knew how to do it. Still, that is more difficult than the Docker example I give above.

like image 192
djangofan Avatar answered Nov 14 '22 23:11

djangofan