spockframework / spockframework/spock
Shorter way to define expected exception class together with message
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 23
This snippet works ok:
then:
def e = thrown(HostException)
e.message == "No active testcase"
while following doesn't catch the exception:
then:
thrown(HostException).message == "No active testcase"
It could be good to support such shortcut definition.
Reported by irium.now on 2009-04-22 17:53:02
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 with the two then: snippets and the existing thrown(HostException) expression to trace how exception conditions are evaluated. The work is done when the shorter expression also checks the exception message and preserves the existing behavior for the separate variable-and-comparison form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100