How to fail build in case of a SurefireBooterForkException?

I sometimes have SurefireBooterForkException but the jenkins build is not failed or even test failures are stated (i.e. build is green) and one has to recognize oneself that tests are simply missing in the test result, i.e. there is no information about tests that could not be run.

I found https://issues.apache.org/jira/browse/SUREFIRE-1426 where this is discussed for the configuration parameter -Dmaven.test.failure.ignore, but I don't use this parameter.

Which parameters could also have impact? How could I force a SurefireBooterForkException to verify if that happens reproducible or if other side effects need to be relevant, too?

I don't know if that is important, but I have seen this in integration tests with a fully deployed application, i.e. Selenium tests running in a real scenario (not only Unit tests).

1 answer

  • answered 2018-11-08 08:45 OkieOth

    In my case, the OpenJdk backport to Ubuntu was an issue. I could not predict scenarios in which this bug becomes a problem, but I noticed the bug on every latest Ubuntu-based distributions; older versions were not affected.

    To tackle this, I appended the following POM snippet to the Surefire plugin configurations:

    <useSystemClassLoader>false</useSystemClassLoader>
    

    Next, I configured the JAVA_OPTIONS environment variable for Maven processes:

    _JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true
    

    NOTE: It is important that the variable is passed to the entire call to Maven and the Surefire plugin.

    #!/bin/bash
    
    scriptPos=${0%/*}
    
    # This is a workaround script for a bug in the OpenJDK backport on Ubuntu.
    # Bug causes problems in the Surefire plugin.
    # https://issues.apache.org/jira/browse/SUREFIRE-1588
    # https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class
    
    _JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true mvn $@
    

    In Bamboo, it is sufficient to set the environment variable within a plan's configuration.