spockframework / spockframework/spock
Interaction on null mock object shall throw exception
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
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"
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the handling for the shown nullObj.toString() >> "" interaction and its current silent behavior. Verify the change with the provided TestSpec scenario: the interaction should throw IllegalArgumentException and report the message required by the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100