Skip to content

Tests fail on systems with non ENGLISH locale #994

@DarkAtra

Description

@DarkAtra

When running mvn clean install -Dgpg.skip=true on a system with a german locale, many tests fail with:

java.lang.NumberFormatException: For input string: "18,58"

The number in the exception messages changes randomly as it is generated by javafaker. It seems like javafaker does not respect the locale when formatting prices, see: DiUS/java-faker#433.

Possible solutions:

  • update javafaker to https://github.com/datafaker-net/datafaker (which fixes the underlying issue) - note that datafaker 2.x requires at least java 17
  • explicitly set the locale in code for all tests that depend on javafaker, like so: Locale.setDefault(Locale.ENGLISH);
  • explicitly set the locale in surefire like so:
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>${surefire.version}</version>
      <configuration>
          <argLine>@{argLine} -Duser.language=en -Duser.country=EN</argLine>
      </configuration>
    </plugin>
    

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions