如何在基于Python的Robot框架中包含Java测试库 [英] How to include Java test libraries in a Python based Robot framework

查看:53
本文介绍了如何在基于Python的Robot框架中包含Java测试库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个基于Python的Robot框架.在测试块框的一侧是一个Python模拟器,为此我编写了与之交互的测试库.在另一侧,有一个Java库.

I am trying to get a Robot framework in place based on Python. On one side of the test block box is a Python simulator for which I have written test libraries to interact with. On the other side there is a Java library.

关于如何在基于Python的Robot框架内与Java类进行交互,我有以下问题:

I have the following questions on how to interact with Java classes from within the Python based Robot framework:

  • 选项A:
    Robot Framework(基于Python)无缝地包括Python测试库和Java测试库.阅读机器人文档后,我认为这是不可能的吗?还是有可能,但没有在任何地方明确提及?我的理解是用户需要Jython才能将Java类包含在Robot框架中,但是我目前正在使用Python.

  • Option A:
    Robot Framework (based on Python) includes both the Python test libraries and Java test libraries seamlessly. After reading through the Robot documentation I do not believe this is possible? Or maybe it’s possible and not clearly mentioned anywhere? My understanding is the user needs Jython in order to include the Java classes in the Robot framework but I am currently using Python.

选项B:
使用Python测试库,并使用JNI和任何可能的选项(py4j,pyjnius,javbridge等)包含Java类.

Option B:
Use the Python test library and include the Java classes using JNI and any possible options (py4j, pyjnius, javbridge etc).

选项C:
我目前正在使用所需的选项(更像CLI)从Python测试库中调用Java可执行文件,然后解析日志以匹配所讨论的测试.

Option C:
I am currently calling the Java executable from within the Python test library with the required option (more like a CLI) and then parsing the logs to match for the test in question.

最后一个选项正在工作,但我想知道这三个之间的最佳方法.

The last option is working but I would like to know the best approach between these three.

推荐答案

要直接使用用Java编写的关键字,您需要使用jython.

To directly use keywords written in java, you'll need to use jython.

另一种选择是使用远程库接口.您设置了一个小的XML-RPC服务器(使用Java),然后通过为机械手提供服务器的地址来导入该库.

Another option is to use the remote library interface. You set up a little XML-RPC server (in java), then import the library by giving robot the address of the server.

好消息是有人已经编写了基于Java的服务器.参见 https://github.com/ombre42/jrobotremoteserver

The good news is that someone has already written a java based server. See https://github.com/ombre42/jrobotremoteserver

这篇关于如何在基于Python的Robot框架中包含Java测试库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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