Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TempDir in a base class not initialized #1229

Closed
vmj opened this issue Nov 2, 2020 · 0 comments · Fixed by #1230
Closed

TempDir in a base class not initialized #1229

vmj opened this issue Nov 2, 2020 · 0 comments · Fixed by #1230
Labels

Comments

@vmj
Copy link

vmj commented Nov 2, 2020

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
leonard84 added a commit to leonard84/spock that referenced this issue Nov 2, 2020
@leonard84 leonard84 added the bug label Nov 2, 2020
leonard84 added a commit that referenced this issue Nov 2, 2020
szpak added a commit that referenced this issue Sep 22, 2021
A variant of previously fixed:
#1229
szpak added a commit that referenced this issue Sep 22, 2021
A variant of previously fixed:
#1229
szpak added a commit that referenced this issue Sep 22, 2021
A variant of previously fixed:
#1229
leonard84 pushed a commit that referenced this issue Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants