如何在OpenTest框架中导入外部Java库? [英] How to import external Java libraries in OpenTest framework?

查看:93
本文介绍了如何在OpenTest框架中导入外部Java库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何将外部库导入到我的测试中?例如,如果我使用Java库来随机生成名称/数字,该如何在测试中使用它?

谢谢

解决方案

在我回答之前,我建议您应避免使用Java代码(如果可以).例如,一个随机的名称/数字生成器很容易在JavaScript中实现,并且在那里可以找到很多现成的示例.如果是JS代码,则可以使用此处一个>.更好的是,您应该使用OpenTest开箱即用提供的功能: $ randomString .

如果您确实需要使用Java代码,则有两种方法可以使用它:

  • 推荐的方法:按照此处所述创建一个或多个自定义OpenTest关键字.这样一来,您将来可以更轻松地维护测试套件,还可以使团队中的其他成员更轻松地在自己的测试中利用此工作,尤其是在他们不熟悉Java的情况下.
  • 快速而肮脏"的方式:在测试参与者的工作目录中创建一个user-jars目录,并将JAR文件拖放到该目录中.然后,按照此处所述,从JavaScript调用Java代码.. li>

I would like to find out how I can import external libraries into my tests? For example, if i use a Java library for random name/number generation, how do I go about using it in my tests?

Thanks

解决方案

Before I answer, I would advise that you should avoid using Java code, if you can. For example, a random name/number generator is very easy to implement in JavaScript and you can find plenty of ready-made examples out there. If it's JS code, you can easily embed it in your tests using one of the techniques described here. Even better, you should use capabilities that are provided out-of-the-box with OpenTest: $random and $randomString.

If you really need to use Java code, there are two ways to do it:

  • The recommended way: create one or more custom OpenTest keywords as described here. This will make it easier for you to maintain your test suite in the future and it also makes it easier for other members of your team to leverage this work in their own tests, especially if they are not familiar with Java.
  • The "quick and dirty" way: create a user-jars directory in your test actor's working directory and drop the JAR file in there. Then, call your Java code from JavaScript as described here.

这篇关于如何在OpenTest框架中导入外部Java库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆