空手道DSL-在功能文件中使用Java包 [英] Karate DSL - using Java packages in feature files

查看:58
本文介绍了空手道DSL-在功能文件中使用Java包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java Inte rop在空手道功能文件中调用JVM类.它工作正常,但是我在java包中有很多类(大约25个),并且想调用/定义包中的所有类.有任何可能性/方法吗?

I'm calling JVM classes in karate feature file using Java Inte rop. It works well, but I have number of classes (about 25) in java package and would like to call/define all classes in the package. Is there any possibilities/approach?

当前,我正在后台定义25个Java Inte rop变量,并在方案中使用.有什么想法可以定义包本身并在场景中使用相应的类吗?

Currently I'm defining 25 Java Inte rop variables in Background and using in Scenarios. Any idea to define package itself and use corresponding classes in scenarios?

推荐答案

我有一个更好的建议.使用单个Java类,并在其上具有多个静态帮助器方法.

I have a better suggestion. Use a single Java class, and have multiple static helper methods on it.

然后,您只需要初始化一个变量即可.

Then you just need to init a single variable.

* def utils = Java.type('com.mycompany.MyUtils')
* def result = utils.doWork()
* utils.doSomeOtherWork('message', 500)

这篇关于空手道DSL-在功能文件中使用Java包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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