Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import java class, to Robot Framework like library

I can't understand how to import .jar file, in Robot Framework.

Here is the code:

*** Settings ***
Library   MyLibrary

*** Test Cases ***
My Test
    Do Nothing
    Hello    world

and Java:

public class MyLibrary {

    public void hello(String name) {
        System.out.println("Hello, " + name + "!");
    }

    public void doNothing() {
    }

}

After Extracting in .jar, I put in C:\Python27\Lib\site-packages\MyLibrary and I created empty __init__.py file. After I execute my Robot file with: pybot TestJavaLibrary.robot I get this WARN:

[ WARN ] Imported library 'MyLibrary' contains no keywords.
==============================================================================
TestJavaLibrary
==============================================================================
My Test                                                               | FAIL |
No keyword with name 'Do Nothing' found.

How to use this jar, like external library?

like image 825
Rumen Avatar asked Sep 20 '26 01:09

Rumen


1 Answers

  1. you need jython to run your tests, it means you need to install jython to run tests.
  2. no special action is needed when importing your java library.
  3. you need to tell jybot where to find your java library or classes.
    jybot --pythonpath <the_path_to_your_java_classes> your_tests
    //e.g.   
    jybot --pythonpath c:/test-project/target/classes  your_tests
like image 136
Jinlxz Liu Avatar answered Sep 21 '26 15:09

Jinlxz Liu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!