RSM RSM - 1 year ago 71
Groovy Question

Passing a value in a where: block in Spock test

Is it possible to pass a value in where block like this.

I have tried this. But it fails and gives MissingPropertyException.

And I want the name1 and name2 to be inside the method.

def "length of names #name"() {
def name1 = "Spock"
def name2 = "Java"

name.size() == length

name || length
name1 || 5
name2 || 2

Answer Source

Try this:

def "test length of names"()  {
        name.size() == length   


def getTestData(){
        [["Ram"  ,3 ] ,["Test" ,4] ]

Hope that helps!!!


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download