我有一个在大多数机器上运行良好的单元测试但是一个ubuntu盒似乎无法比较特殊字符“?”。角色本身应该是â。在我的机器上,eclipse控制台正常显示我们应该使用哪种编码来确保这种方式有效。
The extracted text was wrong expected:<...tons. Il jette le bl[?me sur ....
but was:<...tons. Il jette le bl[?me sur .....
使用Java 1.7
使用Maven 2在Eclipse Juno中运行测试有没有人有想法......?
修改
仅当通过Maven测试运行单元测试时才会出现此行为,而不是在执行运行时看到Junit测试...在maven配置中我们有
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
为maven用户设置和模块的pom.xml文件设置了哪个。
答案 0 :(得分:2)
尝试将{1}}
中的maven-compiler-plugin
部分内的<build>
放入UTF-8编码
pom.xml
答案 1 :(得分:1)
我们通过@Slawomir Jaranowski解决方案解决了THIS问题。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
</configuration>
</plugin>
答案 2 :(得分:0)
我最近在JUnit中遇到了Unicode问题。您可以尝试在JUnit测试中或程序本身中使用有问题的Unicode字符的转义表示法。
在您的情况下,请尝试使用/ u0032而不是使用â。