集成 Groovy 和 Robot Framework
谁能告诉我如何将 Groovy 测试库导入到机器人框架中?
我正在使用用 Groovy 编写的机器人框架来测试库(文件名是 ProxyTest.groovy)。在尝试运行测试套件时,我收到以下错误:
[ ERROR ] Invalid syntax in file 'c:\users\admin\desktop\proxy1\proxy.html' in table 'Setting': Importing test library 'ProxyTest' failed: ImportError: No module named ProxyTest
Can anyone tell me how to import Groovy test libraries into robot framework?
I'm using robot framework for test library written in Groovy (filename is ProxyTest.groovy
). While trying to run the test suite I'm getting the following error:
[ ERROR ] Invalid syntax in file 'c:\users\admin\desktop\proxy1\proxy.html' in table 'Setting': Importing test library 'ProxyTest' failed: ImportError: No module named ProxyTest
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须将 groovy 源代码编译为 .class 文件,使它们在 CLASSPATH 中可用,使用
jybot
启动 Robot Framework 并像这样导入库You have to compile the groovy source code to .class files, make them available in CLASSPATH, start Robot Framework with
jybot
and import the library like this这个伎俩是行不通的。出现此问题的原因是 Robot 框架在执行场景时不编译 Groovy 或 Java 源代码。这就是为什么你需要将编译的groovy字节码放入类路径中,并放置一个完整的限定类名而不是ProxyTest.groovy
如果你使用maven来构建你的项目,那么你可以使用robotframework-maven-plugin,它将之后编译您的代码并立即执行场景。有一个快速教程,介绍如何设置您的用于从 Eclipse 或命令行运行场景的 Java(或 Groovy)项目。
This trick won't work. This problem appears because Robot framework doesn't compile Groovy or Java sources while executing scenarios. That's why you need to put compiled groovy bytecode into class path and put a full qualified class name instead of ProxyTest.groovy
If you use maven to build your project then you can use robotframework-maven-plugin that will compile your code and execute scenarios right after that. There is a quick tutorial of how to setup your Java (or Groovy) project to run scenarios from Eclipse or command line.