spockframework / spockframework/spock

Make it possible to used mocked objects in a where block table

Open
#346 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Module-Core Type-NewFeature
Dominant language
Java
Stars
3.6k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

Originally reported on Google Code with ID 224

It is currently impossible to use a mock in a "where" block table.

Would it be possible to allow the creation of mocked object within a "where" block?

This would allow things like this:

where:
    Human james = Mock()
    james.isCaptain() >> true
    Human staff = Mock()
    staff.isCaptain() >> false

     isAboard             | shipCanMove
    [james]               | true
    [james, staff]        | true
    [staff, james]        | true
    [staff]               | false
    [staff, staff]        | false
    [staff, staff, staff] | false


Reported by jolleon on 2012-01-25 04:26:41

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files, tests, or entry points. Start by reproducing the shown where-block table with mocked objects and trace how where blocks and Mock creation are handled; done means the example can define mocks in the where block and all listed rows pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.