Junit在法语字符串断言上失败 [英] Junit fails on french string assertion

查看:74
本文介绍了Junit在法语字符串断言上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单元测试在大多数机器上都能正常工作,但是一个ubuntu框似乎无法比较特殊字符?".字符本身应为.在我的机器上,eclipse控制台会正常显示它,我们应该使用哪种编码来确保它能正常工作.

I have a unit test that works well on most machine but one ubuntu box seems to not be able to compare special characters "?". The character itself should be â. On my machine the eclipse console displays it normally which encoding should we be playing with to ensure that this works.

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中运行的

The test is ran within Eclipse Juno using Maven 2 using java 1.7

有人有主意吗??

仅在通过Maven测试运行单元测试时才看到此行为,而在执行As Junit测试运行时则看不到...在maven配置中,我们拥有

This behavior is only seen when running the unit test through Maven test and not when performing a run As Junit test... In the maven configuration we have the

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

既为maven用户设置又在模块的pom.xml文件中进行了设置.

Which is set for both maven user settings and within the module's pom.xml file.

推荐答案

尝试将UTF-8编码放入pom.xml

Try to put UTF-8 encoding to maven-compiler-plugin inside <build> section in your pom.xml

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.5.1</version>
  <configuration>
    <source>1.6</source>
    <target>1.6</target>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>

这篇关于Junit在法语字符串断言上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆