jeudi 30 janvier 2020

Unexpected Spock failure on File.createTempFile()

I have these lines in a given block of a test/feature:

log.debug( "subdir1 |$subdir1| class ${subdir1.class}")
File.createTempFile​( 'blub', 'odt', subdir1 )

The log message is:

2020-01-30 08:34:47,433 - 1404 ms [Test worker] DEBUG core.IndexCreationSpec [core.IndexCreationSpec] $spock_feature_1_26:706 
subdir1 |/tmp/junit8540540913300320698/subdir1| class class java.io.File

But I'm getting the following Spock fail on the createTempFile line:

groovy.lang.MissingMethodException: No signature of method: static java.io.File.createTempFile​() is applicable for argument types: (String, String, File) values: [blub, odt, /tmp/junit8540540913300320698/subdir1] Possible solutions: createTempFile(java.lang.String, java.lang.String, java.io.File), createTempFile(java.lang.String, java.lang.String), createNewFile(), createTempDir(), createTempDir(java.lang.String, java.lang.String)

This method of File is not one I use very often. There are workarounds to create Files with temporary filenames. But I'm simply baffled by the Spock fail. Is it a Spock failure (i.e. should I submit a bug report)?

Aucun commentaire:

Enregistrer un commentaire