我有一个Java类,看起来像这样:
package com.charandeepmatta.keywords;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywords;
@RobotKeywords
public class SampleKeywords {
@RobotKeyword
public void printToErrorStream() {
System.err.println("!!! Hello from keyword developed in java ...");
}
}
我的测试用例看起来像这样
*** Settings ***
Library org.robotframework.javalib.library.AnnotationLibrary /**.class
*** Test Cases ***
Keyword defined in java class can print to error stream
Print To Error Stream
当我尝试在RIDE上运行它时,它会给我以下错误
[ ERROR ] Error in file 'C:\Users\BFerreira\git\robotframework-maven-project\src\main\robot\suite\OwnDevelopedKeywordTestCase.txt':
Importing test library 'org.robotframework.javalib.library.AnnotationLibrary' failed:
ImportError: No module named org.robotframework.javalib.library
Traceback (most recent call last):
None
PYTHONPATH:
C:\Python27\lib\site-packages\robot\libraries
C:\Python27\lib\site-packages
C:\Windows\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages\wx-2.8-msw-unicode
.
C:\Users\user1\git\robotframework-maven-project\src\main\robot\suite
一切都在同一个类路径中,任何人都可以帮忙吗?
答案 0 :(得分:2)
从输出的外观来看,您不是executing with jybot/Jython。 Jython需要在Python解释器中加载Java类。如果你是这样的话输出会是什么样子:
PYTHONPATH:
C:\apps\Python27\Lib\site-packages
C:\apps\jython2.5.3\Lib\site-packages\setuptools-0.6c11-py2.5.egg
C:\apps\jython2.5.3\Lib\site-packages\pip-1.2.1-py2.5.egg
C:\apps\jython2.5.3\Lib
__classpath__
__pyclasspath__/
C:\apps\jython2.5.3\Lib\site-packages
.
c:\ws\local
CLASSPATH:
C:\apps\jython2.5.3\jython.jar
提醒一句:如果您运行Robot Framework jar(例如java -jar robotframework-2.5.3.jar ...),如某些示例所示,则忽略所有类路径设置。您必须将所有依赖项放在一个jar中才能使用...