Search code examples
gradlespock

Change truncation settings in Gradle


When running Spock tests in Gradle (5.6.3) I see that the output can look something like this:

> :functionalTest > Executing test com.examp...baar.baaaaz.MyCustomGradleTasksP

In reality it should be like this if it showed the full path to the test running:

> :functionalTest > Executing test com.example.fooo.baar.baaaaz.MyCustomGradleTasksPluginFunctionalTest

Maybe it would also tell me which of the actual functional tests from that class it is running?

Is there a way to tell Gradle not to do this truncation so I can see all information?


Solution

  • It seems to be an internal implementation detail of Gradle itself:

    private String createProgressLoggerDescription(TestDescriptorInternal testDescriptor) {
            DecoratingTestDescriptor decoratingTestDescriptor = (DecoratingTestDescriptor)testDescriptor;
            DefaultTestClassDescriptor defaultTestClassDescriptor = (DefaultTestClassDescriptor)decoratingTestDescriptor.getDescriptor();
            return "Executing test " + JavaClassNameFormatter.abbreviateJavaPackage(defaultTestClassDescriptor.getClassName(), MAX_TEST_NAME_LENGTH);
        }
    

    https://github.com/gradle/gradle/blob/master/subprojects/testing-base/src/main/java/org/gradle/api/internal/tasks/testing/logging/TestWorkerProgressListener.java#L103

    It may be possible to override this by implementing your own logger for Gradle as described here: https://docs.gradle.org/current/userguide/logging.html#sec:changing_what_gradle_logs