Search code examples
groovybddspockspock-reports

Condition not Satisfied at Groovy


have a problem here, and I'm really tired of try to find an solution...

Every time I use this:

Map<Object, Object2> comparisonMap = new HashMap<>()
comparisonMap.put(object, object2)

I receive an error message like this:

Condition not satisfied:

comparisonMap.put(object, object2)
|             |   |       |
|             |   object  object2
|             null
[object:object2]

And I'm really stuck at this. Can someone help me to figure out a solution?


Solution

  • You must be doing this in a then block.

    then: blocks are for asserting something is true.

    Map.put is a void method, so groovy will evaluate this as false

    The solution is to do this put in the correct block... You don't show your spock test though, so I can't suggest a solution