[英]Can I pass all the <jvmarg> parameters to an ant junit task from a single file
所以我有類似
<junit fork="true" forkmode="perTest">
<jvmarg value="-Darg.to.pass.our.tests.one=arg1">
<jvmarg value="-Darg.to.pass.our.tests.two=arg2">
<jvmarg value="-Darg.to.pass.our.tests.three=arg3">
...
<jvmarg value="-Darg.to.pass.our.tests.enn=argN">
</junit>
我知道理想是分叉一次,但是由於我不願討論的原因,這對於我們的測試是不可能的。
我的問題是,我可以做些什么:
<junit fork="true" forkmode="perTest">
<jvmargs file="standard_args.properties">
</junit>
我正在尋找在測試執行時指定不同參數的自由。
我知道我能做
<junit fork="true" forkmode="perTest">
<jvmarg value="${arg.one}">
<jvmarg value="${arg.two}">
...
<jvmarg value="${arg.enn}">
</junit>
而且我確實使用了這種方法,但是這對傳遞的參數的確切數目有所期望。
有什么想法嗎?
由於要傳遞給測試的所有屬性都是系統屬性(-Dxxx = yyy),因此您應該考慮使用syspropertyset
(請參閱JUnit的 ant文檔):
<property file="standard_args.properties"/>
...
<junit fork="true" forkmode="perTest">
<syspropertyset>
<propertyref prefix="standard.arg"/>
</syspropertyset>
</junit>
假設您的屬性文件standard_args.properties
包含測試的屬性,並且所有這些屬性均以特定的模式開頭(即,上例中的standard.arg
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.