如何分发空手道测试框架? [英] How to distribute Karate testing framework?
问题描述
问题陈述:每个服务都有一个单独的存储库.在多个服务存储库中使用通用框架的最佳方法是什么?
Problem statement: Every service has a separate repository. what is the best way to use a common framework across several service repositories?
我们正在尝试使用空手道"创建一个API测试自动化框架. 在这里,我们要创建一个框架(可以分发(例如:jar)),以便可以在所有微服务项目存储库中使用.
We are trying to create an API test automation framework using "Karate". Here we want to create a framework(Which can be distributed(example:jar)) such that it can be used across all of the microservice project repositories.
推荐答案
作为空手道的创建者,我强烈建议您不要这样做.从长远来看,这将使您的所有项目都依赖于一个通用框架-并且您应尝试减少家庭种植"产品的创建.构架.特别是对于测试框架,您应尽量避免强迫团队依赖于您需要维护和版本控制的其他库.
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.
也就是说,由于空手道可以从classpath:
读取文件,因此您可以船"具有通用Java类甚至功能或JS文件的JAR文件,您的所有项目都可以继承或重用"这些文件.实际上, karate-base.js
旨在解决常见的引导程序逻辑或变量/从JAR文件提供的参数.
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.
简短答案:使用常规Java技术(Maven/Gradle)创建可重复使用的JAR文件.有多种方法来使用JAR文件中的资源(Java,*.feature
,JS).如何构造Maven(或Gradle)项目来实现这一目标,完全取决于您.
Short Answer: use normal Java techniques (Maven / Gradle) to create a re-usable JAR file. 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.
对于那些寻求如何创建可运行"文件的用户, JAR,请参阅 https://stackoverflow.com/a/56553194/143475
for those looking for how to create a "runnable" JAR, please see https://stackoverflow.com/a/56553194/143475
这篇关于如何分发空手道测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!