spockframework / spockframework/spock
Dynamic method names in interactions
Open
Nobody has claimed this yet.
Module-Core
Type-Enhancement
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported on Google Code with ID 132
Specify interactions on method names defined by a variable
It is very useful when several methods share testing code. You could parameterize the
methods name to test. Example:
def 'm1, m2 and m3 delegate its execution'(){
given:
def myObject = myObject(delegateMock)
when:
myObject."$methodName"()
then:
1 * delegateMock."do$methodName"()
where:
methodName << ['m1', 'm2', 'm3']
}
Reported by eamodeorubio on 2010-10-15 15:26:48
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
The issue names no source file, test, or entry point. Start by locating existing interaction and data-driven specification tests, then try the supplied parameterized method-name example. Done means interactions accept method names built from variables and the example passes for m1, m2, and m3.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100