Skip to content

Commit 657dfce

Browse files
committed
OrderExtensionSpec: condense redundant code in embedded spec
by extracting logging code into base spec.
1 parent 53a890d commit 657dfce

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

spock-specs/src/test/groovy/org/spockframework/smoke/extension/OrderExtensionSpec.groovy

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,32 @@ class OrderExtensionSpec extends EmbeddedSpecification {
4444
compiler.addClassMemberImport(OrderExtensionSpec)
4545
compiler.addClassImport(Order)
4646
specs = compiler.compileWithImports("""
47-
class FirstSpec extends Specification {
47+
abstract class BaseSpec extends Specification {
4848
@Shared execution = new SpecExecution(spec: this.class.simpleName)
4949
def setup() { execution.features << specificationContext.currentFeature.name }
5050
def cleanupSpec() { executionsTL.get() << execution }
51+
}
52+
53+
class FirstSpec extends BaseSpec {
5154
def one() { expect: true }
5255
def two() { expect: true }
5356
def three() { expect: true }
5457
}
5558
5659
@Order(-1)
57-
class SecondSpec extends Specification {
58-
@Shared execution = new SpecExecution(spec: this.class.simpleName)
59-
def setup() { execution.features << specificationContext.currentFeature.name }
60-
def cleanupSpec() { executionsTL.get() << execution }
60+
class SecondSpec extends BaseSpec {
6161
def foo() { expect: true }
6262
@Order(99) def bar() { expect: true }
6363
@Order(-5) def zot() { expect: true }
6464
}
6565
66-
class ThirdSpec extends Specification {
67-
@Shared execution = new SpecExecution(spec: this.class.simpleName)
68-
def setup() { execution.features << specificationContext.currentFeature.name }
69-
def cleanupSpec() { executionsTL.get() << execution }
66+
class ThirdSpec extends BaseSpec {
7067
def "some feature"() { expect: true }
7168
@Order(1) def "another feature"() { expect: true }
7269
def "one more feature"() { expect: true }
7370
}
7471
75-
class FourthSpec extends Specification {
76-
@Shared execution = new SpecExecution(spec: this.class.simpleName)
77-
def setup() { execution.features << specificationContext.currentFeature.name }
78-
def cleanupSpec() { executionsTL.get() << execution }
72+
class FourthSpec extends BaseSpec {
7973
def 'feature X'() { expect: true }
8074
def 'feature M'() { expect: true }
8175
@Order(-1) def 'feature D'() { expect: true }

0 commit comments

Comments
 (0)