我如何传递参数从蚂蚁JUnit测试? [英] How do I pass parameters to a Junit test from Ant?

查看:302
本文介绍了我如何传递参数从蚂蚁JUnit测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用蚂蚁的Junit下进行硒Test.My测试用例需要读取文件
含有试验数据(以便完成数据驱动检验)。
我不介意在测试用例嵌入文件名,但我想有目录的名称,其中的
数据文件存储参数build.xml文件。

I'm using Junit under Ant to perform Selenium Test.My test cases need to read files which contain test data(in order to accomplish data driven test). I don't mind embedding the file names in the test cases, but I'd like to have the name of the directory where the data files are stored parameterized in the build.xml file.

什么是传似从build.xml文件分解成测试用例信息的最佳方式是什么?
它是使用ant属性是个好主意?
是否有可能从build.xml文件注入Junit4参数?

What's the best way to pass information like that from build.xml down into the test cases? Is it a good idea to use ant property? Is it possible to inject Junit4 parameter from build.xml?

推荐答案

借助的JUnit 任务接受嵌套 sysproperty 元素。

The junit task accepts nested sysproperty elements.

<junit fork="no">
  <sysproperty key="mydatadir" value="${whatever}"/>
  ...
</junit>

您可以在您的测试中使用访问这些<一个href=\"http://download.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#getProperty%28java.lang.String,%20java.lang.String%29\">System.getProperty().

You can access these from within your tests using System.getProperty().

这篇关于我如何传递参数从蚂蚁JUnit测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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