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)?
Update: analysis of string classes
def blub = 'blub'
log.debug( "blub |$blub| class ${blub.class} class2 ${'blub'.class}")
2020-01-30 09:52:34,187 - 1375 ms [Test worker] DEBUG core.IndexCreationSpec [core.IndexCreationSpec] $spock_feature_1_26:709
blub |blub| class class java.lang.String class2 class java.lang.String
Found the answer. It's very odd and no doubt a one-in-a-many-thousand chance of happening. But might help someone, so I propose not deleting the question.
Somehow a mysterious Unicode character, u200B
, "zero-width space" had slipped itself between File.createTempFile
and (
.
Removing this solved the problem! It would appear this was considered to be part of the method I was trying to call. Had I paid more attention to the Groovy formatting (Eclipse, see my answer here) I would have noticed that it was underlined (= "unrecognised method") when it should have been non-underlined and italic (= "recognised static method").