Skip to content

TempDir in a base class not initialized #1229

Description

@vmj

Issue description

The @TempDir doesn't work in base class.

How to reproduce

Given a build.gradle file:

plugins {
    id 'groovy'
}

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.spockframework:spock-core:2.0-M4-groovy-2.5'
}

test {
    useJUnitPlatform()
}

and a src/test/groovy/BaseSpec.groovy file:

import spock.lang.Specification
import spock.lang.TempDir

import java.nio.file.Path

class BaseSpec extends Specification {
    @TempDir Path tmp
}

and a src/test/groovy/FileSpec.groovy file:

class FileSpec extends BaseSpec {
    void "test"() {
        expect:
        tmp != null
    }
}

when the test is executed

gradle test

then it fails

Condition not satisfied:

tmp != null
|   |
|   false
null

Versions

  • Spock 2.0-M4
  • Gradle 6.7
  • Java 11
openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment Zulu11.43+21-CA (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM Zulu11.43+21-CA (build 11.0.9+11-LTS, mixed mode)
  • Groovy 2.5.12 (from transitive dependencies of Spock)
  • IntelliJ IDEA, but also reproduced in command line
  • macOS 10.15.7

Activity

  1. added a commit that references this issue on Nov 2, 2020
    da692a1
  2. added a commit that references this issue on Nov 2, 2020
    b8bfe54
  3. added 3 commits that reference this issue on Sep 22, 2021
  4. added a commit that references this issue on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions