spockframework / spock

The Enterprise-ready testing and specification framework.
https://spockframework.org
Apache License 2.0
3.56k stars 470 forks source link

Query:How to Define TestSuite in spock #942

Open sadasivaiahgoli opened 6 years ago

sadasivaiahgoli commented 6 years ago

I am using spock in my grails project. I wan to run the test classes in a sequence order. When I run all the test cases in a package it runs randomly. I am using linux os. How can we run the test classes in a sequence order. Or How to define test suit in spock .

Vampire commented 5 years ago

Spock is realized by a custom JUnit runner on the base class Specification. So I guess you can simply do it the normal JUnit way. Have one class annotated with @RunWith(Suite) and the @SuiteClasses annotation

comenglish commented 2 days ago

in the spock 1.x i use the case like :

import org.junit.runner.RunWith import org.junit.runners.Suite

@RunWith(Suite.class) @Suite.SuiteClasses([xxx.class,bbb.class]) public class Suite4AllTest {

}

it work good. But in the spock 2.x,it‘s bad。 i'm finding the way now.

Vampire commented 2 days ago

Spock 2.x is a JUnit 5 Platform engine. Just use the JUnit Platform Suite engine to define the Suite. Works fine with Spock and any other engine. https://junit.org/junit5/docs/current/user-guide/#junit-platform-suite-engine