创建具有所有空手道依赖项的测试jar [英] Create tests jar with all the Karate dependencies

查看:68
本文介绍了创建具有所有空手道依赖项的测试jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下项目结构.

  • src/test/java

没有src/main文件夹.

There is no src/main folder.

在src/test/java文件夹中包含一些scala类以及一些Java类.当我使用以下插件构建jar文件时

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:它生成测试jar文件,但相关性不包含在该jar文件中
  • maven-shade-plugin:此插件生成不带测试后缀的jar文件,并将所有依赖项包含在生成的jar中.

请建议

如何生成带有所有依赖项的"tests" jar并解压.或者在这种情况下,如何使用src/test/java文件夹下的所有类以及测试类所需的所有依赖项来生成jar文件

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

推荐答案

是的,空手道测试通常使用 src/test/java 下的代码.除非您将所有东西连接起来以运行测试,否则您不能置于 src/test/main 下,可能是通过点击spring boot控制器来启动它们.然后,在您的Docker容器中,您可以从运行的Spring Boot应用程序开始测试.这是非常不标准的,我不建议您这样做.

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.

相反,我只是从Maven docker映像开始,并构建您自己的映像,该映像知道如何将测试文件(未jard)复制到映像中,然后您就无需全部将其jar打包.我在这里做了一个例子( https://github.com/djangofan/karate-test-Prime-example ),已正确处理了docker出口代码.

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.

空手道站点上有一些文档可用于制作独立的空手道罐,但有关如何执行此操作的细节的文档则很少.我敢打赌,如果您知道怎么做的话,它会奏效.但是,这比我上面给出的Docker示例要困难得多.

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.

这篇关于创建具有所有空手道依赖项的测试jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆