如何分发空手道测试框架?

发布于 2025-01-21 13:30:19 字数 1394 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城泪 2025-01-28 13:30:20

作为空手道的创造者,我强烈建议您不要这样做。从长远来看,这使您的所有项目都取决于一个常见的框架 - 您应该尝试减少“家庭成长”框架的创建。特别是对于测试框架,您应该尽量不要强迫团队依靠需要维护和版本控制的其他库。重复使用可能造成的弊大于利,尤其是在测试的背景下,请参见在Google测试博客上的本文

也就是说,由于空手道可以class class path: 您可以将Jar文件“运送”带有常见Java类的JAR文件,甚至可以将所有项目都可以继承或“重新使用”的功能或JS文件。实际上求解从JAR文件提供的常见引导逻辑或变量 /参数。

简短答案:使用普通的Java技术(Maven/Gradle)创建可重复使用的JAR文件,例如将您的功能文件和JS文件放入src/main/*中,而不是src/test /*。有多种方法可以从JAR文件中使用资源(Java,*。功能)。您如何构建Maven(或Gradle)项目以实现这一目标。

编辑:对于那些寻找如何创建“可运行”罐的人,请参阅 htttps://stackover.com.com.com/a/56553194/1434/1434755

即使使用独立罐子,您也可以自定义类: https://karatelabs.github.io/karate/karate-netty/#custom-classpath

As the creator of Karate, I strongly recommend you don't do this. In the long term this makes all your projects depend on one common framework - and you should try to reduce the creation of "home grown" frameworks. Especially for a testing framework, you should try not to force teams to depend on an additional library which you need to maintain and version-control. Re-use can cause more harm than good especially in the context of testing, see this article at the Google Testing Blog.

That said, since Karate can read files from the classpath: you can "ship" a JAR file with common Java classes and even feature or JS files that all your projects can inherit from or "re use". In fact the karate-base.js has been designed to solve for common bootstrap logic or variables / parameters being supplied from a JAR file.

Short Answer: use normal Java techniques (Maven / Gradle) to create a re-usable JAR file, e.g. put your feature files and JS files in src/main/* and not src/test/*. There are multiple ways to use resources (Java, *.feature, JS) from a JAR file. It is up to you how to structure your Maven (or Gradle) projects to make this happen.

EDIT: for those looking for how to create a "runnable" JAR, please see https://stackoverflow.com/a/56553194/143475

And even if using the standalone JAR, you can customize the classpath: https://karatelabs.github.io/karate/karate-netty/#custom-classpath

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文