开发者

How do I pass parameters to a Junit test from Ant?

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 min开发者_如何学运维d 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.

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?


The junit task accepts nested sysproperty elements.

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜