spockframework / spockframework/spock

Spock + Spring - using helper methods in where clause that use spring injected beans skips test

Open
#402 0 comments 0 reactions 0 assignees View on GitHub

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 280

Tests are skipped (i.e not recognized as spock tests) when using helper methods in a
where-clause that use spring injected beans.

Example:

@ContextConfiguration("classpath:some-spring.xml")
class SomeSpec extends Specification {

    @Resource testdata
    @Autowired someService

    def "a feature"() {
        expect:
        someService.login(user) == true

        where:
        user                    | comment
        getAdmin()          | "Admin has access"
        getRegularUser() | "Regular users have access" 
    }

   def getAdmin() {
        testData.getAdmin()
   }

   def getRegularUser() {
        testData.getRegularUser()
   }


}



What version of Spock and Groovy are you using?
Spock version 0.7-groovy-2.0
Spock-spring version 0.7-groovy-2.0
Groovy version 2.0.5
Running in Intellij idea 11.1.3

Please provide any additional information below. You can also assign
labels.

Since these tests are just skipped, it is hard to find out why they are failing. If
possible; it would be nice if an error message would be raised.

Reported by odin.hole.standal on 2012-11-07 14:27:17

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

Start by reproducing the supplied SomeSpec example with Spock 0.7-groovy-2.0, spock-spring 0.7-groovy-2.0, and Groovy 2.0.5. Trace the Spock/Spring handling of helper methods in a where clause; done means the feature is recognized and runs, or a useful error explains why it is skipped.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.