Is it possible to parameterize a Spec name with a value from a data table?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is it possible to parameterize a Spec name with a value from a data table?

olivier nguyen

Hello everyone,

I am wondering if it is possible to parameterize the name of a spec with a value from a data table to know which scenario failed.

For example, I have:

def "checks access to dashboard as a(n) #role"(){

setup:

to LoginPage

login(role)


when:

at HomePage

searchModule.submitSearch testAccount.email


then:

at landingPage


cleanup:

topMenu.logout()


where:

role         | landingPage

"ADMIN" | DashboardPage

"OPERATOR" | DashboardPage

"FINANCE" | DashboardPage

"VOUCHER" | SearchIndexPage

}

So depending on a role, I am supposed to land on a different page.

I wish there is a way to say: "checks access to dashboard as a(n) ADMIN" failed.

 

Thanks!

 

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to parameterize a Spec name with a value from a data table?

Peter Niederwieser
Administrator
Yes there is. You just have to annotate the method or class with @spock.lang.Unroll. Then use `#role`, `#landingPage`, etc. in the method name.

Cheers,
Peter

On Oct 16, 2012, at 1:06 AM, olivier nguyen <[hidden email]> wrote:

Hello everyone,

I am wondering if it is possible to parameterize the name of a spec with a value from a data table to know which scenario failed.

For example, I have:


def "checks access to dashboard as a(n) #role"(){

setup:

to LoginPage

login(role)


when:

at HomePage

searchModule.submitSearch testAccount.email


then:

at landingPage


cleanup:

topMenu.logout()


where:

role         | landingPage

"ADMIN" | DashboardPage

"OPERATOR" | DashboardPage

"FINANCE" | DashboardPage

"VOUCHER" | SearchIndexPage

}


So depending on a role, I am supposed to land on a different page.

I wish there is a way to say: "checks access to dashboard as a(n) ADMIN" failed.

 

Thanks!

 


--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to parameterize a Spec name with a value from a data table?

olivier nguyen
Thank you Peter.

I saw the @Unroll annotation before in some docs but it wasn't intuitive at a glance what it was used for.

Anyways, thank you! 

On Monday, October 15, 2012 8:30:20 PM UTC-7, Peter Niederwieser wrote:
Yes there is. You just have to annotate the method or class with @spock.lang.Unroll. Then use `#role`, `#landingPage`, etc. in the method name.

Cheers,
Peter

On Oct 16, 2012, at 1:06 AM, olivier nguyen <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="aZM6wylRK7YJ">olivi...@...> wrote:

Hello everyone,

I am wondering if it is possible to parameterize the name of a spec with a value from a data table to know which scenario failed.

For example, I have:


def "checks access to dashboard as a(n) #role"(){

setup:

to LoginPage

login(role)


when:

at HomePage

searchModule.submitSearch testAccount.email


then:

at landingPage


cleanup:

topMenu.logout()


where:

role         | landingPage

"ADMIN" | DashboardPage

"OPERATOR" | DashboardPage

"FINANCE" | DashboardPage

"VOUCHER" | SearchIndexPage

}


So depending on a role, I am supposed to land on a different page.

I wish there is a way to say: "checks access to dashboard as a(n) ADMIN" failed.

 

Thanks!

 


--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="aZM6wylRK7YJ">spockfr...@googlegroups.com.
To unsubscribe from this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="aZM6wylRK7YJ">spockframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spockframework/-/r-cY4KTBvh0J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to parameterize a Spec name with a value from a data table?

David De Groot
Hello,

If you add @Unroll at the spec / class level, how do you annotate the list of values that you'd like to loop through? I tried adding a "where:" after the last feature method in my Spec, but spock is complaining.

Could someone give an example of how to loop through a list of values or a Map such as this when @Unroll is specified at the spec level:

where:

role          | landingPage

"ADMIN" | DashboardPage

"OPERATOR" | DashboardPage

"FINANCE" | DashboardPage

"VOUCHER" | SearchIndexPage


Thanks!

David 

On Tuesday, 16 October 2012 16:27:22 UTC-4, olivier nguyen wrote:
Thank you Peter.

I saw the @Unroll annotation before in some docs but it wasn't intuitive at a glance what it was used for.

Anyways, thank you! 

On Monday, October 15, 2012 8:30:20 PM UTC-7, Peter Niederwieser wrote:
Yes there is. You just have to annotate the method or class with @spock.lang.Unroll. Then use `#role`, `#landingPage`, etc. in the method name.

Cheers,
Peter

On Oct 16, 2012, at 1:06 AM, olivier nguyen <[hidden email]> wrote:

Hello everyone,

I am wondering if it is possible to parameterize the name of a spec with a value from a data table to know which scenario failed.

For example, I have:


def "checks access to dashboard as a(n) #role"(){

setup:

to LoginPage

login(role)


when:

at HomePage

searchModule.submitSearch testAccount.email


then:

at landingPage


cleanup:

topMenu.logout()


where:

role         | landingPage

"ADMIN" | DashboardPage

"OPERATOR" | DashboardPage

"FINANCE" | DashboardPage

"VOUCHER" | SearchIndexPage

}


So depending on a role, I am supposed to land on a different page.

I wish there is a way to say: "checks access to dashboard as a(n) ADMIN" failed.

 

Thanks!

 


--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To view this discussion on the web visit <a href="https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J&#39;;return true;">https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
For more options, visit this group at <a href="http://groups.google.com/group/spockframework?hl=en" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/spockframework?hl\75en&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/spockframework?hl\75en&#39;;return true;">http://groups.google.com/group/spockframework?hl=en.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to parameterize a Spec name with a value from a data table?

Kostis Kapelonis
The documentation of @Unroll is pretty clear

"The Unroll annotation can also be put on a spec class. This has the
same effect as putting it on every data-driven feature method that is
not already annotated with Unroll"

Unroll affects the name of the feature (i.e. the unit test method).
Putting it on the Spec level does not mean that it affects the Spec
name in any way. It is just a shortcut that saves you time for placing
it over all features (Imagine that you have a class with 20 methods).

Also, all Spock blocks exist inside methods only. Putting a where:
block outside of a feature is not supposed to work. The hierarchy is
Spec -> feature -> block. A Specification (class), contains features
(methods), that themselves contain blocks (labels).

Kostis

On Wed, Feb 24, 2016 at 5:48 PM, David De Groot
<[hidden email]> wrote:

> Hello,
>
> If you add @Unroll at the spec / class level, how do you annotate the list
> of values that you'd like to loop through? I tried adding a "where:" after
> the last feature method in my Spec, but spock is complaining.
>
> Could someone give an example of how to loop through a list of values or a
> Map such as this when @Unroll is specified at the spec level:
>
> where:
>
> role          | landingPage
>
> "ADMIN" | DashboardPage
>
> "OPERATOR" | DashboardPage
>
> "FINANCE" | DashboardPage
>
> "VOUCHER" | SearchIndexPage
>
>
> Thanks!
>
> David
>
> On Tuesday, 16 October 2012 16:27:22 UTC-4, olivier nguyen wrote:
>>
>> Thank you Peter.
>>
>> I saw the @Unroll annotation before in some docs but it wasn't intuitive
>> at a glance what it was used for.
>>
>> Anyways, thank you!
>>
>> On Monday, October 15, 2012 8:30:20 PM UTC-7, Peter Niederwieser wrote:
>>>
>>> Yes there is. You just have to annotate the method or class with
>>> @spock.lang.Unroll. Then use `#role`, `#landingPage`, etc. in the method
>>> name.
>>>
>>> Cheers,
>>> Peter
>>>
>>> On Oct 16, 2012, at 1:06 AM, olivier nguyen <[hidden email]> wrote:
>>>
>>> Hello everyone,
>>>
>>> I am wondering if it is possible to parameterize the name of a spec with
>>> a value from a data table to know which scenario failed.
>>>
>>> For example, I have:
>>>
>>>
>>> def "checks access to dashboard as a(n) #role"(){
>>>
>>> setup:
>>>
>>> to LoginPage
>>>
>>> login(role)
>>>
>>>
>>> when:
>>>
>>> at HomePage
>>>
>>> searchModule.submitSearch testAccount.email
>>>
>>>
>>> then:
>>>
>>> at landingPage
>>>
>>>
>>> cleanup:
>>>
>>> topMenu.logout()
>>>
>>>
>>> where:
>>>
>>> role         | landingPage
>>>
>>> "ADMIN" | DashboardPage
>>>
>>> "OPERATOR" | DashboardPage
>>>
>>> "FINANCE" | DashboardPage
>>>
>>> "VOUCHER" | SearchIndexPage
>>>
>>> }
>>>
>>>
>>> So depending on a role, I am supposed to land on a different page.
>>>
>>> I wish there is a way to say: "checks access to dashboard as a(n) ADMIN"
>>> failed.
>>>
>>>
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Spock Framework - User" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
>>> To post to this group, send email to [hidden email].
>>> To unsubscribe from this group, send email to
>>> [hidden email].
>>> For more options, visit this group at
>>> http://groups.google.com/group/spockframework?hl=en.
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups
> "Spock Framework - User" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/spockframework.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to parameterize a Spec name with a value from a data table?

David De Groot

Ah. Gotcha. Thanks.

On Mar 8, 2016 5:54 PM, "Kostis Kapelonis" <[hidden email]> wrote:
The documentation of @Unroll is pretty clear

"The Unroll annotation can also be put on a spec class. This has the
same effect as putting it on every data-driven feature method that is
not already annotated with Unroll"

Unroll affects the name of the feature (i.e. the unit test method).
Putting it on the Spec level does not mean that it affects the Spec
name in any way. It is just a shortcut that saves you time for placing
it over all features (Imagine that you have a class with 20 methods).

Also, all Spock blocks exist inside methods only. Putting a where:
block outside of a feature is not supposed to work. The hierarchy is
Spec -> feature -> block. A Specification (class), contains features
(methods), that themselves contain blocks (labels).

Kostis

On Wed, Feb 24, 2016 at 5:48 PM, David De Groot
<[hidden email]> wrote:
> Hello,
>
> If you add @Unroll at the spec / class level, how do you annotate the list
> of values that you'd like to loop through? I tried adding a "where:" after
> the last feature method in my Spec, but spock is complaining.
>
> Could someone give an example of how to loop through a list of values or a
> Map such as this when @Unroll is specified at the spec level:
>
> where:
>
> role          | landingPage
>
> "ADMIN" | DashboardPage
>
> "OPERATOR" | DashboardPage
>
> "FINANCE" | DashboardPage
>
> "VOUCHER" | SearchIndexPage
>
>
> Thanks!
>
> David
>
> On Tuesday, 16 October 2012 16:27:22 UTC-4, olivier nguyen wrote:
>>
>> Thank you Peter.
>>
>> I saw the @Unroll annotation before in some docs but it wasn't intuitive
>> at a glance what it was used for.
>>
>> Anyways, thank you!
>>
>> On Monday, October 15, 2012 8:30:20 PM UTC-7, Peter Niederwieser wrote:
>>>
>>> Yes there is. You just have to annotate the method or class with
>>> @spock.lang.Unroll. Then use `#role`, `#landingPage`, etc. in the method
>>> name.
>>>
>>> Cheers,
>>> Peter
>>>
>>> On Oct 16, 2012, at 1:06 AM, olivier nguyen <[hidden email]> wrote:
>>>
>>> Hello everyone,
>>>
>>> I am wondering if it is possible to parameterize the name of a spec with
>>> a value from a data table to know which scenario failed.
>>>
>>> For example, I have:
>>>
>>>
>>> def "checks access to dashboard as a(n) #role"(){
>>>
>>> setup:
>>>
>>> to LoginPage
>>>
>>> login(role)
>>>
>>>
>>> when:
>>>
>>> at HomePage
>>>
>>> searchModule.submitSearch testAccount.email
>>>
>>>
>>> then:
>>>
>>> at landingPage
>>>
>>>
>>> cleanup:
>>>
>>> topMenu.logout()
>>>
>>>
>>> where:
>>>
>>> role         | landingPage
>>>
>>> "ADMIN" | DashboardPage
>>>
>>> "OPERATOR" | DashboardPage
>>>
>>> "FINANCE" | DashboardPage
>>>
>>> "VOUCHER" | SearchIndexPage
>>>
>>> }
>>>
>>>
>>> So depending on a role, I am supposed to land on a different page.
>>>
>>> I wish there is a way to say: "checks access to dashboard as a(n) ADMIN"
>>> failed.
>>>
>>>
>>>
>>> Thanks!
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Spock Framework - User" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/spockframework/-/lIROyjZieS8J.
>>> To post to this group, send email to [hidden email].
>>> To unsubscribe from this group, send email to
>>> [hidden email].
>>> For more options, visit this group at
>>> http://groups.google.com/group/spockframework?hl=en.
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups
> "Spock Framework - User" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/spockframework.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Spock Framework - User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/spockframework/oqx8FpgSlkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...