How to include Java test libraries in a Python bas

2019-02-11 04:21发布

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条回答
我命由我不由天
2楼-- · 2019-02-11 04:29

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

查看更多
登录 后发表回答