spockframework / spockframework/spock
Data Driven Specs
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
It is an often requested feature and with the new flexibility that the JUnit Platform gives us, we can finally implement it in a nice way. (This issue supersedes #668).
Goals
- Offer a way to execute a whole
Specificationfor a set of parameters, similar to data-driven features. - A data-driven
Specificationshould behave like a normal one, with the addition that there are injected parameters. - This feature should integrate well with the existing functionality in terms of UX/DX. It should feel natural.
Open Questions
- How do we deal with inheritance?
- Forbid Inheritance
- Create the Cartesian product of the parameters
- Treat them as extensions, requiring same size and just join both parameters
- How do we define the data-variables?
- with a special static
wheremethod - with a static inner class that is either annotated or implements a certain marker interface and has a
wheremethod or something similar
- with a special static
- How do we inject the data-variables?
- automatically define them as properties with the same name
- require the user to define the properties in the spec, allowing typing
- a combination of the above
- if we use a the inner class approach (2.ii) we can just inject a instance of that class and have the properties be members of that class, either explicit or implicit. This would have the added benefit of isolating them visually in the code.
- How do we deal with spring or similar extensions
- the spring extension can currently only inject in non-shared fields (there are a workarounds for that https://github.com/spockframework/spock/issues/76#issuecomment-241698357). However, those will probably not work for the spec level.
- How do we deal with
@SharedandsetupSpec/cleanupSpecfor Spec iterations- Add some kind of
@SharedForIterationandsetupSpecIteration/cleanupSpecIteration - don't support iteration specific sharing
- something else
- Add some kind of
- How to report during discovery (currently, data-driven features are reported purely dynamic, if we did the same the specs then they wouldn't report any features during discovery)
- Don't report any features during discovery
- Distinguish between data-driven and non-data-driven specs and report feature for the latter
- Somehow detect self contained data providers (i.e., ones without field or function access) and run them during discovery, (this could be ported to features as well)
- something else
Please comment: @spockframework/supporter
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 reviewing the existing data-driven feature behavior and the JUnit Platform integration mentioned in the issue. Work through the open questions on inheritance, data definition and injection, extensions, lifecycle methods, and discovery reporting. Done means a decided design and an implementation that makes data-driven Specifications behave like normal ones with injected parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100