How do I set file.encoding for a junit test in ant?

来源:互联网 发布:cms监控设置回放 编辑:程序博客网 时间:2024/06/08 04:33

JUnit supports a child element <jvmarg ...> which should do what you want.

<junit fork="yes">
    <jvmarg value="-Dfile.encoding=UTF-8"/>

  ...
</junit>

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.