如何设置的file.encoding在蚂蚁JUnit测试? [英] How do I set file.encoding for a junit test in ant?
问题描述
我不太用<一做href=\"http://stackoverflow.com/questions/1339352/how-do-i-set-dfile-encoding-within-ants-build-xml\">file.encoding和蚂蚁。我如何设置的的file.encoding 的对蚂蚁JUnit测试?在的JUnit 的Ant任务不支持的编码的属性一样的的javac 的任务一样。
I'm not quite done with file.encoding and ant. How do I set the file.encoding for junit tests in ant? The junit ant task doesn't support the encoding attribute like the javac task does.
我试着运行«蚂蚁-Dfile.encoding = UTF-8»和«ANT_OPTS = - 指定-Dfile.encoding = UTF-8蚁»没有成功。 System.getProperty测试中(file.encoding的)仍返回的的MacRoman 的
I've tried running «ant -Dfile.encoding=UTF-8» and «ANT_OPTS="-Dfile.encoding=UTF-8" ant» without success. System.getProperty("file.encoding") within a test still returns MacRoman.
推荐答案
JUnit的支持的子元素&LT; jvmarg ...&GT;
这应该做你想要什么。
JUnit supports a child element <jvmarg ...>
which should do what you want.
<junit fork="yes">
<jvmarg value="-Dfile.encoding=UTF-8"/>
...
</junit>
我假设你使用了叉= YES
属性,因为这开始了试运行一个新的JVM,这样的参数在命令行<送入蚂蚁code>蚂蚁-Dfoo =栏不一定传播到JVM运行测试。
I assume you were using the fork=yes
attribute since this starts a new JVM for the test run, thus the parameters you send into ant at the command line ant -Dfoo=bar
do not necessarily propagate to the JVM running the tests.
这篇关于如何设置的file.encoding在蚂蚁JUnit测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!