[英]How do I run test cases for a class written in Java, using Robot framework?
I am trying to learn how to use Robot Framework. 我正在尝试学习如何使用机器人框架。 I created simple Java project, using Eclipse.
我使用Eclipse创建了一个简单的Java项目。 It contains one package -
test
and in this package there is only one class - MyKeywords
. 它包含一个封装-
test
在这个包只有一个类- MyKeywords
。 Here is the class content: 这是课程内容:
package test;
public class MyKeywords {
public String sayHi(String name)
{
return "Hello " +name ;
}
public String sayHi()
{
return "Hello World!";
}
public String typeOf(Object param)
{
return param.getClass().getSimpleName();
}
}
Then I created simple .txt file, whic is supposed to contain the test cases. 然后,我创建了一个简单的.txt文件,其中应该包含测试用例。 Here is the my_suite.txt file:
这是my_suite.txt文件:
*** Settings ***
Library test.MyKeywords
*** Test Cases ***
MyTestCase
${message} say hi
Log ${message}
MyTestCase2
${message} say hi my_name
Log ${message}
MyTestCase3
${message} type of 42
Log ${message}
Whenever, I try to paste the my_suite.txt file into the project directory, it goes under the bin directory. 每当我尝试将my_suite.txt文件粘贴到项目目录中时,它都位于bin目录下。 After that, when I run
pybot my_suite.txt
from the terminal (I am on Mac OS), I got the following message: 之后,当我从终端(在Mac OS上)运行
pybot my_suite.txt
时,出现以下消息:
[ ERROR ] Error in file '/Users/b18/Documents/workspace/Example/my_suite.txt': Importing test library 'test.MyKeywords' failed: Module 'test' does not contain 'MyKeywords'.
[错误]文件'/Users/b18/Documents/workspace/Example/my_suite.txt'中的错误:导入测试库'test.MyKeywords'失败:模块'test'不包含'MyKeywords'。 ============================================================================== My Suite
================================================== ===========================我的套房
============================================================================== MyTestCase
================================================== =========================== MyTestCase
|| FAIL |
失败| No keyword with name 'say hi' found.
找不到名称为“ say hi”的关键字。 ------------------------------------------------------------------------------ MyTestCase2
-------------------------------------------------- ---------------------------- MyTestCase2
|| FAIL |
失败| No keyword with name 'say hi' found.
找不到名称为“ say hi”的关键字。 ------------------------------------------------------------------------------ MyTestCase3
-------------------------------------------------- ---------------------------- MyTestCase3
|| FAIL |
失败| No keyword with name 'type of' found.
找不到名称为“类型”的关键字。 ------------------------------------------------------------------------------ My Suite
-------------------------------------------------- ----------------------------我的套房
|| FAIL |
失败| 3 critical tests, 0 passed, 3 failed 3 tests total, 0 passed, 3 failed ============================================================================== Output: /Users/b18/Documents/workspace/Example/output.xml Log:
3个关键测试,0个通过,3个失败总共3个测试,0个通过,3个失败================================= ===========================================输出:/用户/b18/Documents/workspace/Example/output.xml日志:
/Users/b18/Documents/workspace/Example/log.html Report: /Users/b18/Documents/workspace/Example/report.html/Users/b18/Documents/workspace/Example/log.html报告:/Users/b18/Documents/workspace/Example/report.html
Where is my mistake and what am I missing? 我的错误在哪里,我想念什么?
You're mixing languages here. 您在这里混合语言。
You are using Java keywords, with pybot (which is pure python - and doesn't support java). 您正在使用Java关键字和pybot(这是纯python-不支持Java)。
You need to use jybot instead (you can download the jar and run it with java) 您需要改为使用jybot(您可以下载jar并使用Java运行它)
Jybot is based on Jython - and supports python and java code. Jybot基于Jython-支持python和java代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.