简体   繁体   English

启动Maveryx测试应用程序时如何指定环境变量?

[英]How can environment variables be specified when launching a Maveryx test application?

Maveryx is an open source test automation framework for testing the user-interface of a Java application. Maveryx是一个开放源代码测试自动化框架,用于测试Java应用程序的用户界面。 When the framework executes the application under test, it uses an associated launch file. 当框架执行测试中的应用程序时,它使用关联的启动文件。 This is an XML file that contains the application launch settings (eg main class, arguments, classpath, JRE …). 这是一个XML文件,其中包含应用程序启动设置(例如,主类,参数,类路径,JRE…)。

It seems to me that there should also be a field where environment variables could be specified. 在我看来,还应该有一个可以指定环境变量的字段。 But I have not been able to find such a field in the user manual or online forum. 但是我无法在用户手册或在线论坛中找到这样的字段。

Is there any way to set environment variables for the application under test. 有什么方法可以为被测应用程序设置环境变量。

Note that the variables must not only be accessible to the java application under test itself, but also to any to child processes and native code libraries used by the application (ie via JNI). 请注意,变量不仅必须可以被测试的Java应用程序本身访问,而且还必须可以被该应用程序使用的子进程和本机代码库(例如,通过JNI)访问。

I know I can specify environment variables in the command shell that starts the Maveryx test, but I'd rather have Maveryx do it so that it is specific to the test underway and so that the environment variables do not pollute the parent shell. 我知道我可以在启动Maveryx测试的命令外壳中指定环境变量,但我宁愿Maveryx进行此操作,以使其特定于正在进行的测试,并且环境变量不会污染父外壳。

Thanks! 谢谢!

EDIT: After banging my head against Maveryx for a week or two, I eventually found that it was simply too limited. 编辑:在对Maveryx撞了我的头一两个星期后,我最终发现它太有限了。 I discovered that Maveryx is an abstraction layer on top of the abbot Java GUI Test Framework . 我发现Maveryx是abbot Java GUI测试框架之上的抽象层。 Abbot itself turned out to be a very flexible and powerful framework that is much more capable and extensible than Maveryx (however there may be some cases where the latter is sufficient). 方丈自己竟然是一个非常灵活和强大的框架比Maveryx功能更加实用和可扩展的(但可能有一些情况下,后者就足够了)。 My reccomendation to anyone trying to use Maveryx but encountering limitations, is to check out abbot (and its counterpart test script application, costello). 对于任何尝试使用Maveryx但遇到限制的人,我的建议是检出方丈(及其对应的测试脚本应用程序costello)。

It is not possible to set the environment variables for the application under test directly in the AUT's launch file (xml). 不能直接在AUT的启动文件(xml)中为被测应用程序设置环境变量。

You can set the environment variables as described here . 您可以按照此处所述设置环境变量。

Or, programmatically, as in this post . 或者,以编程方式(如本文中的内容) In this case you have set the environment variables in your test script before launching the application under test. 在这种情况下,您必须在启动测试中的应用程序之前在测试脚本中设置环境变量。

For example: 例如:

@BeforeClass
public static void setUpBeforeClass() throws Exception {
     /* set here the env. variables */
}

@Before
public void setUp() throws Exception {
    Bootstrap.startApplication(xmlFile); //launch the AUT
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM