How to include Java test libraries in a Python based Robot framework

空扰寡人 提交于 2019-12-18 18:05:25

问题


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.

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

  • 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.

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

  • 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.


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/32820792/how-to-include-java-test-libraries-in-a-python-based-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!