Encoding in Maven Tests not working properly
The maven surefire plugin also needs to read the files as UTF-8 otherwise it wont do it :). I had tried something like this before but with the wrong Element in <configuration/>
...
Proper configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
Set (Windows) environment variable JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF8
The other answer (set encoding to Surefire config) did not solve my issue.
After setting JAVA_TOOL_OPTIONS, no surefire configuration is needed.
I had to only set two Windows environment variables:
- JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF8 (thanks to @joro)
- MAVEN_OPTS to -Dfile.encoding=UTF8