Home > database >  Change time format for "Time elapsed:" in Maven Build Logs
Change time format for "Time elapsed:" in Maven Build Logs

Time:01-11

I have a long running test suite and once run is completed, maven build logs are available in console. The issue is it is not in proper decimal format. Is there anyway to make it decimal.

Current log: Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3,289.634 s - in TestSuite

Due to comma in time elapsed 3,289.634 s facing issue. This is effecting in parsing xml cvc-datatype-valid.1.2.1: '3,289.634' is not a valid value for 'decimal'.

Appreciate any help here.

Thanks!

Desire to change the time format.

CodePudding user response:

Unfortunately there is no way to fix this other that surefire code change and re-build.

The string is formed using this logic.

static String formatElapsedTime( double runTime )
{
    NumberFormat numberFormat = NumberFormat.getInstance( Locale.ENGLISH );
    numberFormat.setGroupingUsed( true );
    numberFormat.setMinimumFractionDigits( 0 );
    numberFormat.setMaximumFractionDigits( 3 );
    return numberFormat.format( runTime / MS_PER_SEC );
}

So no environmental settings would change this behavior. You can change true to false and rebuild your surefire classes to get what you need.

CodePudding user response:

You can try out the timeOut property of surefire. you would need to add the following to your pom.xml file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M4</version>
            <configuration>
                <timeOut>
                    <timeUnit>SECONDS</timeUnit>
                    <format>%3.3f</format>
                </timeOut>
            </configuration>
        </plugin>
    </plugins>
</build>
  • Related