Encoding in Maven Tests not working properly

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.


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>