JUnit supports a <jvmarg ...> child element, which should do what you want.
<junit fork="yes"> <jvmarg value="-Dfile.encoding=UTF-8"/> ... </junit>
I assume that you used the fork=yes attribute since it launches a new JVM for a test run, so the parameters you send to ant at the ant -Dfoo=bar command line do not necessarily apply to the JVM that runs the tests.
source share