简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM