Search code examples
gradleintellij-ideaspock

Cases Not Individually Named When Running SpockFramework Tests in Gradle Project with "Where"


When running tests from Intellij or on commandline via gradle, the test cases for a where clause are not broken out and named

    final static String artifact = 'artifact'
    final static String version = '1.2.3'

    def getLayoutSpecificPathHappyPath(
         def platform, def expected) {
        given:
        when:
        def result = artifactoryManager.getLayoutSpecificPath(
                         platform, artifact, version)

        then:
        result == expected

        where:
        platform | prefix        | expected
        'npm'    | 'prefix'      | "${artifact}/-"
        'maven'  | 'prefix'      | "${artifact}/${version}"

Result

ArtifactoryManagerTest > getLayoutSpecificPathv2HappyPath FAILED

I think I've got a setting in my gradle file that is preventing printing of the case data making it easier to see which of the where's failed.


Solution

  • You can control the detail by setting the displayGranularity in TestLogging and enabling the logging of relevant events.

    The display granularity of the events to be logged. For example, if set to 0, a method-level event will be displayed as "Test Run > Test Worker x > org.SomeClass > org.someMethod". If set to 2, the same event will be displayed as "org.someClass > org.someMethod".

    tasks.test {
        testLogging {
            events ("passed", "skipped", "failed")
            displayGranularity = 1
        }
    }