简体   繁体   中英

Import Java library in RIDE

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM