junit在eclipse中运行,中文没有问题,但是用ant构建的时候,遇到中文都是乱码。
考虑肯定是ant中字符编码的问题引起的。
解决办法:
在junit标签中加入下面这句就ok了
<sysproperty key="file.encoding" value="UTF-8" />
eg: <junit printsummary="no" haltonfailure="yes" haltonerror="yes" fork="yes" >
<formatter type="plain" usefile="false"/>
<formatter type="xml" />
<sysproperty key="file.encoding" value="UTF-8" />
<test name="org.athrun.ios.instrumentdriver.test.TaoTestMainTest"
todir="${junit.report.dir}"/>
<classpath>
<!-- pathelement location="${libs.dir}"/>-->
<fileset dir="${libs.dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${jssh.dir}"/>
<pathelement location="${build.src.dir}"/>
<pathelement location="${socket.classes.dir}"/>
<pathelement location="${test.classes.dir}"/>
<pathelement location="${config.classes.dir}"/>
</classpath>
</junit>