0

I have a Groovy class like this:

// All import stuffs

class Test extends GebSpec{

    def setupSpec() {
    // Works just fine
    }

    def setup() {
           // Works just fine
    }

    // Now I have some helper functions
    // and I want them to execute exactly in the same order
    def "function 1" (){
        // code goes here
    }

    def "function 2" (){
        // code goes here
    }

    def "function 3" (){
        // code goes here
    }

}

I want to execute the helper functions exactly one after another. At this moment, they start executing randomly but they should follow the order like, at first "function 1", then "function 2" and at last "function 3". I tried with adding @Stepwise before the class but that did not help. I would really appreciate any suggestion or help.

Sharif Mamun
  • 3,508
  • 5
  • 32
  • 51
  • 1
    Have a look at http://stackoverflow.com/questions/13575972/determine-order-of-execution-of-spock-tests – Fran García Jan 18 '14 at 00:09
  • 1
    Helper methods won't get executed at all, unless you call them yourself. If you mean test methods (also called feature methods), they will get executed in declaration order in any case (although you should add `@Stepwise`). – Peter Niederwieser Jan 18 '14 at 00:24
  • @FranGarcía: thanks for the link. I already tried that but it didn't work for me. – Sharif Mamun Jan 19 '14 at 01:39
  • @PeterNiederwieser: Even if I call them one after another, still they behave randomly. I don't know why! – Sharif Mamun Jan 19 '14 at 01:40
  • 1
    I don't understand what you are saying. Please provide a self-contained, reproducible example that demonstrates your problem. – Peter Niederwieser Jan 19 '14 at 01:57
  • Thanks Peter for getting back to this. If you go to the link below, you will see that only writing @Stepwise before the Class definition starts executing the functions one after another but I am sure that's not the case. Actually, you don't need to call these functions again, isn't it? They should start executing one after another, am I right? I am sorry if I am not clear. Please let me know if I am not. http://stackoverflow.com/questions/13575972/determine-order-of-execution-of-spock-tests – Sharif Mamun Jan 19 '14 at 04:45
  • Chances are your spec is not written correctly then. Again, a self-contained, reproducible example would help. – Peter Niederwieser Jan 22 '14 at 02:34

1 Answers1

0

spock doesnot identifies it as a spock test unless it is ended with word "spec"

so you need to do two modifications. 1. make it as testspec 2. use @stepwise annotation. It should work