Reputation: 18124
I'm trying to check that 2 strings are equal but I'm hitting. Both Strings are empty:
Condition not satisfied:
versionTagPrefix == ""
| |
"" false
2 differences (0% similarity)
("")
(--)
I've also tried equals:
Condition not satisfied:
"".equals(versionTagPrefix)
| |
false ""
Versions:
compile 'org.codehaus.groovy:groovy-all:2.0.1'
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
Upvotes: 0
Views: 2708
Reputation: 11937
As far as i know, groovy has many implementations of Strings.
When you see messages in output/error stream you are probably looking at value of toString()
instead of actual content of object.
To go in deep and debug, use .properties
attribute on objects.
groovy:000> i=10; s1="$i"; "type=${s1.class}\n
content=${s1.properties}\n
out=${s1.toString()}"
===> type=class org.codehaus.groovy.runtime.GStringImpl
content=[values:[10],
class:class org.codehaus.groovy.runtime.GStringImpl,
bytes:[49, 48], strings:[, ], valueCount:1]
out=10
groovy:000>s2="10"; "type=${s2.class}\n
contents=${s2.properties}\n
out=${s2.toString()}"
===> type=class java.lang.String
contents=[class:class java.lang.String, bytes:[49, 48], empty:false]
out=10
Though in this case s1 == s2
, you might have a situation where s1 != s2
but s1.toString() == s2.toString()
assert versionTagPrefix?.toString() == ""
Upvotes: 3