Use to check if two objects are the same: Groovy value.shouldBe sameInstance(anotherValue) value.shouldNotBe sameInstance(anotherValue) Check matchers/import-and-dependencies Import And Dependencies for prerequisites. Java actual(value).shouldBe(sameInstance(anotherValue)); actual(value).shouldNotBe(sameInstance(anotherValue)); Check matchers/import-and-dependencies Import And Dependencies for prerequisites.