Adding setup method / firing @Before event dynamically

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding setup method / firing @Before event dynamically

Bartosz Majsak-2
Hi,

I am wondering if there is a way to dynamically create a setup method or hook into the spock lifecycle at this point? The use case I have is that Arquillian relies on firing before event to perform all necessary work before the test can be executed, for example injecting the component under test. If I don't have a dummy "setup" method defined this results in test failures. 

I was wondering if there is some way to hook into the spock lifecycle at the same moment when "setup" method is evaluated so that integration with Arquillian lifecycle will work and won't force the user to write such a useless "setup" method.

Many thanks for any hints.

Cheers,
Bartosz

--
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 http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding setup method / firing @Before event dynamically

J. David Beutel
I think that could be done by writing an IGlobalExtension.  For example, see how JUnitFixtureMethodsExtension implements BEFORE.  (Spock is some inspiring code, by the way.)

Cheers,
11011011

On 2015-11-22 22:49 , Bartosz Majsak wrote:
Hi,

I am wondering if there is a way to dynamically create a setup method or hook into the spock lifecycle at this point? The use case I have is that Arquillian relies on firing before event to perform all necessary work before the test can be executed, for example injecting the component under test. If I don't have a dummy "setup" method defined this results in test failures. 

I was wondering if there is some way to hook into the spock lifecycle at the same moment when "setup" method is evaluated so that integration with Arquillian lifecycle will work and won't force the user to write such a useless "setup" method.

Many thanks for any hints.

Cheers,
Bartosz
--
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 http://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 http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding setup method / firing @Before event dynamically

Michael Kutz

You can always put that setup in an AbstractAquillanSpec and use it as your super class.


J. David Beutel <[hidden email]> schrieb am Di., 24. Nov. 2015, 00:29:
I think that could be done by writing an IGlobalExtension.  For example, see how JUnitFixtureMethodsExtension implements BEFORE.  (Spock is some inspiring code, by the way.)

Cheers,
11011011


On 2015-11-22 22:49 , Bartosz Majsak wrote:
Hi,

I am wondering if there is a way to dynamically create a setup method or hook into the spock lifecycle at this point? The use case I have is that Arquillian relies on firing before event to perform all necessary work before the test can be executed, for example injecting the component under test. If I don't have a dummy "setup" method defined this results in test failures. 

I was wondering if there is some way to hook into the spock lifecycle at the same moment when "setup" method is evaluated so that integration with Arquillian lifecycle will work and won't force the user to write such a useless "setup" method.

Many thanks for any hints.

Cheers,
Bartosz
--
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 http://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 http://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 http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Adding setup method / firing @Before event dynamically

Bartosz Majsak-2
Thanks for all the hints. I will explore the extension approach. Don't wont to enforce users to stick to some arbitrary super class if I have other means to implement this functionality.

Cheers!

On Tuesday, November 24, 2015 at 7:06:37 AM UTC+1, Michael Kutz wrote:

You can always put that setup in an AbstractAquillanSpec and use it as your super class.


J. David Beutel <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="eKXHkUKTAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jdbe...@...> schrieb am Di., 24. Nov. 2015, 00:29:
I think that could be done by writing an IGlobalExtension.  For example, see how JUnitFixtureMethodsExtension implements BEFORE.  (Spock is some inspiring code, by the way.)

Cheers,
11011011


On 2015-11-22 22:49 , Bartosz Majsak wrote:
Hi,

I am wondering if there is a way to dynamically create a setup method or hook into the spock lifecycle at this point? The use case I have is that Arquillian relies on firing before event to perform all necessary work before the test can be executed, for example injecting the component under test. If I don't have a dummy "setup" method defined this results in test failures. 

I was wondering if there is some way to hook into the spock lifecycle at the same moment when "setup" method is evaluated so that integration with Arquillian lifecycle will work and won't force the user to write such a useless "setup" method.

Many thanks for any hints.

Cheers,
Bartosz
--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="eKXHkUKTAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">spockframewor...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="eKXHkUKTAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">spockfr...@googlegroups.com.
Visit this group at <a href="http://groups.google.com/group/spockframework" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/spockframework&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/spockframework&#39;;return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="eKXHkUKTAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">spockframewor...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="eKXHkUKTAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">spockfr...@googlegroups.com.
Visit this group at <a href="http://groups.google.com/group/spockframework" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/spockframework&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/spockframework&#39;;return true;">http://groups.google.com/group/spockframework.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.