3 Answers
3

This is probably due to the default encoding used for your Java source files. The ö in the string literal in the JUnit source code is probably being converted to something else when the test is compiled.

To avoid this, use Unicode escapes (\uxxxx) in the string literals in your JUnit source code:

Ok, I guess then there is some configuration for maven junit , or the compiler plugin.
–
RomanNov 21 '10 at 12:31

@Roman - in your Maven pom.xml, you need to specify the encoding of your source files to match your editor. This will ensure consistent compilation in any environment. docs.codehaus.org/display/MAVENUSER/…
–
McDowellNov 21 '10 at 13:11

McDowell: Changing your default encoding is fine as long as you work alone, or at least in a "controlled" environment. However things get more difficult if you are part of a team, as everyone might be working on a different environment. Using Unicode escapes in your source files is fool-proof -- file encodings do not matter any more, regardless of what editor / compiler / setup you use.
–
GrodriguezNov 21 '10 at 20:10

This is one of those fundamental Java design flaws: there is no place to specify the (ASCII-compatible) encoding in the source file itself. It is insane that we are expected to stick to 7 bits when the language has 16 bit chars, plus a nasty hack for the rest of them.
–
tchristNov 22 '10 at 4:00

This worked for me in Android Studio. I changed the project encodings to UTF-8 and it worked.
–
Russ WheelerOct 20 '14 at 10:32