Skip to content

Interaction on null mock object shall throw exception #2339

@AndreasTu

Description

@AndreasTu

An interaction on a null object shall report an exception to the user, that the interaction does not make sense.
This shall help users to detect such interactions, which will work as intended.

This is a breaking change, because previously such interactions are silent, although probably senseless.

class TestSpec extends Specification {

  def "Interaction on null Object shall report error"() {
    given:
    Object nullObj = null

    when:
    nullObj .toString() >> ""

    then:
    def ex = thrown(IllegalArgumentException)
    ex.message == "Interaction on null object is invalid. TODO message"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions