在空手道DSL框架中,我们如何添加自定义步骤定义以将其功能扩展到REST功能之外? [英] In the Karate DSL Framework, how can we add custom step definitions to expand its functionalities beyond REST capabilities?

查看:69
本文介绍了在空手道DSL框架中,我们如何添加自定义步骤定义以将其功能扩展到REST功能之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解空手道背后的理念是不必添加自定义步骤定义.但是,我们在项目中执行的REST API测试更加集成,因此我们必须验证MongoDB集合,ActiveMQ和SQL Server DB中的POST响应.无论如何,是否可以轻松添加自定义步骤定义以将空手道DSL框架扩展到其REST功能之外?我尝试下载源代码并将其作为Maven项目导入,但是遇到了许多依赖性问题.

I understand the philosophy behind Karate is to not have to add custom Step definitions. However, the REST API Testing we perform in our project is more integrated so we have to verify POST responses in MongoDB collections, ActiveMQ, and a SQL Server DB. Is there anyway to easily add custom step definitions to expand the Karate DSL Framework beyond its REST Capabilities? I tried downloading the source code and importing it as a Maven project but I came across many dependency issues.

推荐答案

通过演示示例使用JDBC调用数据库:

It is very easy to extend Karate via Java Interop. The best way to understand this, is to look at this demo example which uses JDBC to call a database: dogs.feature.

这里值得一提的是,如果您从Java返回了Map(或MapList)-您将返回空手道中的JSON-land,并且可以使用match空手道的另一种由数据驱动的优点.

It is worth calling out here that if you return a Map (or List of Maps) from Java - you are back in JSON-land within Karate, and you can use match and all the other data-driven goodness of Karate.

是的,这很容易-而且您没有步骤定义和依赖项注入的不必要的开销.

Yes, it is that easy - and you don't have the un-necessary overhead of Step Definitions and dependency injection.

希望这可以清楚说明为什么根本不需要步骤定义!

Hope this makes it clear as to why you don't need step definitions at all !

这篇关于在空手道DSL框架中,我们如何添加自定义步骤定义以将其功能扩展到REST功能之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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