空手道框架中如何使用"faker"库? [英] How to use 'faker' libraries in karate framework?
本文介绍了空手道框架中如何使用"faker"库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用"faker"库在JSON文件中生成伪数据,如下所示.
I'd like to use the 'faker' library to generate fake data in JSON file as below.
在karate-config.js中,我执行以下操作:
In karate-config.js, I do the following:
var faker = require('faker');
在sample.json中:
In sample.json:
{
'firstName': '#(faker.name.firstName)'
'city' : '#(faker.address.city)'
}
但是我收到类似无法在'karate-config.js'中找到'require'关键字"之类的错误消息
But I'm getting error like 'unable to find 'require' keyword in 'karate-config.js'
请对此提供帮助.
推荐答案
空手道不支持NPM或require
关键字.对于复杂的自定义逻辑,建议使用Java互操作.
Karate does not support NPM or the require
keyword. For complex custom logic, the recommendation is to use Java interop.
我的建议是,您应该找到一个执行"faker"功能的Java库并将其集成.
My suggestion is you should find a Java library that does what "faker" does and integrate it.
这篇关于空手道框架中如何使用"faker"库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文