Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use a spock config file. </p> <p>Create annotations for the two types of tests - <code>@Local</code> and <code>@PreProd</code>, for example in Groovy:</p> <pre><code>import java.lang.annotation @Retention(RetentionPolicy.RUNTIME) @Target([ElementType.TYPE, ElementType.METHOD]) @Inherited public @interface Local {} </code></pre> <p>Next step is to annotate your specs accordingly, for example: </p> <pre><code>@Local class SpecificationThatRunsLocally extends GebSpec { ... } </code></pre> <p>Then create a <code>SpockConfig.groovy</code> file next to your <code>GebConfig.groovy</code> file with the following contents:</p> <pre><code>def gebEnv = System.getProperty("geb.env") if (gebEnv) { switch(gebEnv) { case 'local': runner { include Local } break case 'pre-prod': runner { include PreProd } break } } </code></pre> <p><strong>EDIT: It looks like Grails is using it's own test runner which means SpockConfig.groovy is not taken into account when running specifications from Grails. If you need it to work under Grails then the you should use @IgnoreIf/@Require built-in Spock extension annotations.</strong></p> <p>First create a Closure class with the logic for when a given spec should be enabled. You could put the logic directly as a closure argument to the extension annotations but it can get annoying to copy that bit of code all over the place if you want to annotate a lot of specs.</p> <pre><code>class Local extends Closure&lt;Boolean&gt; { public Local() { super(null) } Boolean doCall() { System.properties['geb.env'] == 'local' } } class PreProd extends Closure&lt;Boolean&gt; { public PreProd() { super(null) } Boolean doCall() { System.properties['geb.env'] == 'pre-prod' } } </code></pre> <p>And then annotate your specs:</p> <pre><code>@Requires(Local) class SpecificationThatRunsLocally extends GebSpec { ... } @Requires(PreProd) class SpecificationThatRunsInPreProd extends GebSpec { ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload