Junit fails on french string assertion

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 .....

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

Does anyone have an idea…?

EDIT:

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>

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

Answers

I recently had a problem with Unicode in JUnit. You can try using the escaped notation of the offending Unicode character in the JUnit test, or in the program itself.

In your case, try using /u0032 Instead of using â.

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>