spockframework / spockframework/spock
groovy mocks are not truthy
Open
Nobody has claimed this yet.
Module-Core
Type-Defect
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported on Google Code with ID 316
See the example below.
Regular mocks evaluate to true but groovy mocks resolve to false.
class GroovyMockSpec extends Specification {
def mock = Mock(A)
def groovyMock = GroovyMock(Object)
def "regular mocks are truthy"() {
expect:
mock ?: 'irrelevant' == mock
}
def "groovy mocks are falsey"() {
expect:
groovyMock ?: 'unexpected' == 'unexpected'
}
static interface A {}
}
What version of Spock and Groovy are you using?
0.7-groovy-1.8
Reported by sgo@thinkerit.be on 2013-06-17 12:36:31
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 reproducing the provided GroovyMockSpec example with Spock 0.7-groovy-1.8 and compare the truthiness of regular and Groovy mocks. Trace the existing mock behavior to determine the intended change; done means Groovy mocks evaluate truthily like regular mocks without breaking the example's expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100