Import Java library in RIDE

痞子三分冷 提交于 2019-12-13 14:14:22

问题


I'm trying to use a java library in RIDE. I found a good tutorial( https://blog.codecentric.de/en/2012/06/robot-framework-tutorial-writing-keyword-libraries-in-java/) I follow it, but when the time comes to import and use the java library ( Database Library)in RIDE. It fails. When I look the page with my different imports, the java library is written in red and not in black as the others.

And when I try to run with Jybot, I have the well-known message : [ ERROR ] Error in file 'C:\Users\XXXXXX\Documents\Robot_Test\implementation\DB_Test\Example.html': Importing test library 'org.robot.database.keywords.DatabaseLibrary' failed: ImportError: No module named robot

I follow every line of the tutorial, even the with the set CLASSPATH.

Any idea ? ( I know that this library exist in Python, but I want to write my own java libraries ^^) Thanks


回答1:


This worked for me using:

  • Jython 2.7b4
  • Robotframework 2.8.7
  • Ride 1.3

Create Lib and compile it (you do not need to jar it)

Directory structure is

run_ride.sh
libs/DemoLib.class
tests/DemoLibTest.txt

Excerpt from tests/DemoLibTest.txt:

* Settings
Library           ../libs/DemoLib.class

* Test Cases
DemoLibTest
    Print Demo

Start Ride, switch to tab "Run", choose Execution Profile: jybot, press Start, output is:

Starting test: tests.DemoLibTest.DemoLibTest
20150304 19:13:20.321 :  INFO : ---------- Demo ---------------

To avoid confusion put this line

echo $CLASSPATH

in your Ride startup script in order to ensure that your library is really imported. By the way, in my Ride the import is also marked red. Sometimes restarting Ride might help. But the colour does not mean anything, if your settings are correct.



来源:https://stackoverflow.com/questions/22245240/import-java-library-in-ride

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