如何将黄瓜与Python语言集成 [英] How to integrate cucumber with Python language
本文介绍了如何将黄瓜与Python语言集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几种情况需要对Assertion进行一些数据处理.我知道,可以通过Java Script完成.但是我希望为自定义可重用功能创建一个Utility文件.是否有可能与Python集成,从而可以调用Utility函数.
I have few scenarios which needs some data manipulation for Assertion. I know, it can be done by Java Script. But I wish to create a Utility file for custom reusable functions. Is there any possibility to integrate with Python through which Utility function can be called.
推荐答案
我强烈建议不要这样做.
I strongly advise against it.
如果确实需要,您可以像这样调用命令行python程序:
If you really want, you might be able to call a command-line python program like this:
* def FileUtils = Java.type('com.intuit.karate.FileUtils')
* def runtime = java.lang.Runtime.getRuntime()
* def exec = function(cmd){ return FileUtils.toString(runtime.exec(cmd).getInputStream()) }
* def result = exec('my-python-command')
当然,如果您能够将Python utils公开为REST-API,那是另一种选择:)
Of course if you are able to expose your Python utils as a REST-API, that's another option :)
但是请不要这样做.
这篇关于如何将黄瓜与Python语言集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文