diff --git a/docs/extensions.adoc b/docs/extensions.adoc index 004a3c72b5..257258e6c1 100644 --- a/docs/extensions.adoc +++ b/docs/extensions.adoc @@ -899,21 +899,21 @@ class I extends AbstractMethodInterceptor { I(def s) {} } // On SpecInfo specInfo.addSharedInitializerInterceptor new I('shared initializer') -specInfo.sharedInitializerMethod?.addInterceptor new I('shared initializer method') +specInfo.allSharedInitializerMethods*.addInterceptor new I('shared initializer method') specInfo.addInterceptor new I('specification') specInfo.addSetupSpecInterceptor new I('setup spec') -specInfo.setupSpecMethods*.addInterceptor new I('setup spec method') +specInfo.allSetupSpecMethods*.addInterceptor new I('setup spec method') specInfo.allFeatures*.addInterceptor new I('feature') specInfo.addInitializerInterceptor new I('initializer') -specInfo.initializerMethod?.addInterceptor new I('initializer method') +specInfo.allInitializerMethods*.addInterceptor new I('initializer method') specInfo.allFeatures*.addIterationInterceptor new I('iteration') specInfo.addSetupInterceptor new I('setup') -specInfo.setupMethods*.addInterceptor new I('setup method') +specInfo.allSetupMethods*.addInterceptor new I('setup method') specInfo.allFeatures*.featureMethod*.addInterceptor new I('feature method') specInfo.addCleanupInterceptor new I('cleanup') -specInfo.cleanupMethods*.addInterceptor new I('cleanup method') +specInfo.allCleanupMethods*.addInterceptor new I('cleanup method') specInfo.addCleanupSpecInterceptor new I('cleanup spec') -specInfo.cleanupSpecMethods*.addInterceptor new I('cleanup spec method') +specInfo.allCleanupSpecMethods*.addInterceptor new I('cleanup spec method') specInfo.allFixtureMethods*.addInterceptor new I('fixture method') // on FeatureInfo diff --git a/spock-core/src/main/java/org/spockframework/runtime/SimpleFeatureNode.java b/spock-core/src/main/java/org/spockframework/runtime/SimpleFeatureNode.java index 02142423cc..c99a952839 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/SimpleFeatureNode.java +++ b/spock-core/src/main/java/org/spockframework/runtime/SimpleFeatureNode.java @@ -1,10 +1,14 @@ package org.spockframework.runtime; +import org.opentest4j.TestAbortedException; import org.spockframework.runtime.model.FeatureInfo; +import org.spockframework.util.ExceptionUtil; import spock.config.RunnerConfiguration; import org.junit.platform.engine.*; +import java.util.concurrent.atomic.AtomicReference; + /** * A non-parametric feature (test) that only has a single "iteration". * Contrary to parametric tests - where the iterations are the children - this is the actual test. The execution @@ -29,62 +33,34 @@ public Type getType() { @Override public SpockExecutionContext prepare(SpockExecutionContext context) throws Exception { - return delegate.prepare( - context.withCurrentFeature(getNodeInfo()) - //.withParentId(getUniqueId()) - ); - } - - @Override - public SpockExecutionContext before(SpockExecutionContext context) throws Exception { - context = super.before(context); - ErrorInfoCollector errorInfoCollector = new ErrorInfoCollector(); - context = context.withErrorInfoCollector(errorInfoCollector); - context.getRunner().runSetup(context); - errorInfoCollector.assertEmpty(); - - return context; - } - - @Override - public void around(SpockExecutionContext context, Invocation invocation) { - // Wrap the Feature invocation around the invocation of the Iteration delegate - super.around(context, ctx -> delegate.around(ctx, invocation)); + context = super.prepare(context); + return context.withCurrentFeature(getNodeInfo()); } @Override public SpockExecutionContext execute(SpockExecutionContext context, DynamicTestExecutor dynamicTestExecutor) throws Exception { verifyNotSkipped(getNodeInfo()); - delegate.execute(context, dynamicTestExecutor); - return context; - } - @Override - public void after(SpockExecutionContext context) throws Exception { - ErrorInfoCollector errorInfoCollector = new ErrorInfoCollector(); - context = context.withErrorInfoCollector(errorInfoCollector); - delegate.after(context); - // First the iteration node, then the Feature node - errorInfoCollector.assertEmpty(); - super.after(context); - } - - @Override - public void nodeFinished(SpockExecutionContext context, TestDescriptor testDescriptor, TestExecutionResult result) { - delegate.nodeFinished(context, testDescriptor, result); - super.nodeFinished(context, testDescriptor, result); - } - - @Override - public void nodeSkipped(SpockExecutionContext context, TestDescriptor testDescriptor, SkipResult result) { - // Skipping this Feature implies that the Iteration is also skipped - delegate.nodeSkipped(context, testDescriptor, result); - super.nodeSkipped(context, testDescriptor, result); - } - - @Override - public SkipResult shouldBeSkipped(SpockExecutionContext context) throws Exception { - return delegate.shouldBeSkipped(context); + AtomicReference result = new AtomicReference<>(); + EngineExecutionListener executionListener = new EngineExecutionListener() { + @Override + public void executionSkipped(TestDescriptor testDescriptor, String reason) { + result.set(new TestAbortedException(reason)); + } + + @Override + public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) { + testExecutionResult.getThrowable().ifPresent(result::set); + } + }; + + addChild(delegate); + dynamicTestExecutor.execute(delegate, executionListener); + dynamicTestExecutor.awaitFinished(); + + if (result.get() != null) { + ExceptionUtil.sneakyThrow(result.get()); + } + return context; } - } diff --git a/spock-core/src/main/java/org/spockframework/runtime/model/SpecInfo.java b/spock-core/src/main/java/org/spockframework/runtime/model/SpecInfo.java index 287528214b..be7ff87fa9 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/model/SpecInfo.java +++ b/spock-core/src/main/java/org/spockframework/runtime/model/SpecInfo.java @@ -168,6 +168,12 @@ public MethodInfo getInitializerMethod() { return initializerMethod; } + public Iterable getAllInitializerMethods() { + if (superSpec == null) return CollectionUtil.listOf(getInitializerMethod()); + + return CollectionUtil.concat(superSpec.getAllInitializerMethods(), CollectionUtil.listOf(getInitializerMethod())); + } + public void setInitializerMethod(MethodInfo initializerMethod) { this.initializerMethod = initializerMethod; } @@ -176,6 +182,12 @@ public MethodInfo getSharedInitializerMethod() { return sharedInitializerMethod; } + public Iterable getAllSharedInitializerMethods() { + if (superSpec == null) return CollectionUtil.listOf(getSharedInitializerMethod()); + + return CollectionUtil.concat(superSpec.getAllSharedInitializerMethods(), CollectionUtil.listOf(getSharedInitializerMethod())); + } + public void setSharedInitializerMethod(MethodInfo sharedInitializerMethod) { this.sharedInitializerMethod = sharedInitializerMethod; } @@ -184,6 +196,12 @@ public List getSetupMethods() { return setupMethods; } + public Iterable getAllSetupMethods() { + if (superSpec == null) return getSetupMethods(); + + return CollectionUtil.concat(superSpec.getAllSetupMethods(), getSetupMethods()); + } + public void addSetupMethod(MethodInfo setupMethod) { setupMethods.add(setupMethod); } @@ -192,6 +210,12 @@ public List getCleanupMethods() { return cleanupMethods; } + public Iterable getAllCleanupMethods() { + if (superSpec == null) return getCleanupMethods(); + + return CollectionUtil.concat(superSpec.getAllCleanupMethods(), getCleanupMethods()); + } + public void addCleanupMethod(MethodInfo cleanupMethod) { cleanupMethods.add(cleanupMethod); } @@ -200,6 +224,12 @@ public List getSetupSpecMethods() { return setupSpecMethods; } + public Iterable getAllSetupSpecMethods() { + if (superSpec == null) return getSetupSpecMethods(); + + return CollectionUtil.concat(superSpec.getAllSetupSpecMethods(), getSetupSpecMethods()); + } + public void addSetupSpecMethod(MethodInfo setupSpecMethod) { setupSpecMethods.add(setupSpecMethod); } @@ -208,6 +238,12 @@ public List getCleanupSpecMethods() { return cleanupSpecMethods; } + public Iterable getAllCleanupSpecMethods() { + if (superSpec == null) return getCleanupSpecMethods(); + + return CollectionUtil.concat(superSpec.getAllCleanupSpecMethods(), getCleanupSpecMethods()); + } + public void addCleanupSpecMethod(MethodInfo cleanupSpecMethod) { cleanupSpecMethods.add(cleanupSpecMethod); } diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/Interceptors.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/Interceptors.groovy new file mode 100644 index 0000000000..f036a89f4b --- /dev/null +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/Interceptors.groovy @@ -0,0 +1,347 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.spockframework.smoke + +import org.spockframework.EmbeddedSpecification +import org.spockframework.runtime.extension.ExtensionAnnotation +import org.spockframework.runtime.extension.IAnnotationDrivenExtension +import org.spockframework.runtime.extension.IMethodInvocation +import org.spockframework.runtime.model.SpecInfo +import org.spockframework.specs.extension.Snapshot +import org.spockframework.specs.extension.Snapshotter +import spock.lang.ResourceLock + +import java.lang.annotation.Retention +import java.lang.annotation.RetentionPolicy + +class Interceptors extends EmbeddedSpecification { + @Snapshot + Snapshotter snapshotter + + def setup() { + runner.addClassImport(LifecycleTest) + LifecycleRecorderAndContextTesterExtension.lifecycleOutline = '' + } + + @ResourceLock("LifecycleRecorderAndContextTesterExtension.lifecycleOutline") + def "interceptors are called in the correct order and with the correct context information"() { + when: + runner.runWithImports """ +class SuperSpec extends Specification { + @Shared superShared = 0 + + def superInstance = 0 + + def setupSpec() { + } + + def setup() { + } + + def superFeature1() { + expect: true + } + + def superFeature2() { + expect: true + } + + def superDataFeature1() { + expect: x + where: + x << [true, true] + } + + def superDataFeature2() { + expect: x + where: + x << [true, true] + } + + def cleanup() { + } + + def cleanupSpec() { + } +} + +@LifecycleTest +class SubSpec extends SuperSpec { + @Shared subShared = 0 + + def subInstance = 0 + + def setupSpec() { + } + + def setup() { + } + + def subFeature1() { + expect: true + } + + def subFeature2() { + expect: true + } + + def subDataFeature1() { + expect: x + where: + x << [true, true] + } + + def subDataFeature2() { + expect: x + where: + x << [true, true] + } + + def cleanup() { + } + + def cleanupSpec() { + } +} +""" + + then: + noExceptionThrown() + snapshotter.assertThat(LifecycleRecorderAndContextTesterExtension.lifecycleOutline).matchesSnapshot() + } + + @ResourceLock("LifecycleRecorderAndContextTesterExtension.lifecycleOutline") + def "non-method interceptors are called even without the respective method"() { + when: + runner.runWithImports """ +@LifecycleTest +class FooSpec extends Specification { + def foo() { + expect: true + } + + def bar() { + expect: x + where: + x << [true, true] + } +} +""" + + then: + noExceptionThrown() + snapshotter.assertThat(LifecycleRecorderAndContextTesterExtension.lifecycleOutline).matchesSnapshot() + } + + static class LifecycleRecorderAndContextTesterExtension implements IAnnotationDrivenExtension { + static lifecycleOutline = '' + def indent = '' + + @Override + void visitSpecAnnotation(LifecycleTest annotation, SpecInfo specInfo) { + specInfo.addSharedInitializerInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target != instance + } + proceed(it, 'shared initializer', "$it.spec.name") + } + specInfo.allSharedInitializerMethods*.addInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target == instance + } + proceed(it, 'shared initializer method', "$it.spec.name.$it.method.name()") + } + specInfo.addInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target != instance + } + proceed(it, 'specification', "$it.spec.name") + } + specInfo.addSetupSpecInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target != instance + } + proceed(it, 'setup spec', "$it.spec.name") + } + specInfo.allSetupSpecMethods*.addInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target == instance + } + proceed(it, 'setup spec method', "$it.spec.name.$it.method.name()") + } + specInfo.allFeatures*.addInterceptor { + it.with { + assert spec + assert feature + assert !iteration + assert instance == sharedInstance + assert target != instance + } + proceed(it, 'feature', "$it.spec.name.$it.feature.name") + } + specInfo.addInitializerInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target != instance + } + proceed(it, 'initializer', "$it.spec.name.$it.feature.name") + } + specInfo.allInitializerMethods*.addInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target == instance + } + proceed(it, 'initializer method', "$it.spec.name.$it.feature.name.$it.method.name()") + } + specInfo.allFeatures*.addIterationInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target != instance + } + proceed(it, 'iteration', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex]") + } + specInfo.addSetupInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target != instance + } + proceed(it, 'setup', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex]") + } + specInfo.allSetupMethods*.addInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target == instance + } + proceed(it, 'setup method', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex].$it.method.name()") + } + specInfo.allFeatures*.featureMethod*.addInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target == instance + } + proceed(it, 'feature method', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex].$it.method.name()") + } + specInfo.addCleanupInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target != instance + } + proceed(it, 'cleanup', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex]") + } + specInfo.allCleanupMethods*.addInterceptor { + it.with { + assert spec + assert feature + assert iteration + assert instance != sharedInstance + assert target == instance + } + proceed(it, 'cleanup method', "$it.spec.name.$it.feature.name[#$it.iteration.iterationIndex].$it.method.name()") + } + specInfo.addCleanupSpecInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target != instance + } + proceed(it, 'cleanup spec', "$it.spec.name") + } + specInfo.allCleanupSpecMethods*.addInterceptor { + it.with { + assert spec + assert !feature + assert !iteration + assert instance == sharedInstance + assert target == instance + } + proceed(it, 'cleanup spec method', "$it.spec.name.$it.method.name()") + } + specInfo.allFixtureMethods*.addInterceptor { + it.with { + assert spec + if (method.name.endsWith('Spec')) { + assert !feature + assert !iteration + assert instance == sharedInstance + } else { + assert feature + assert iteration + assert instance != sharedInstance + } + assert target == instance + } + proceed(it, 'fixture method', "$it.spec.name${it.feature?.name?.with { name -> ".$name[#$it.iteration.iterationIndex]" } ?: ''}.$it.method.name()") + } + } + + void proceed(IMethodInvocation invocation, String type, String name) { + lifecycleOutline += "$indent$type start ($name)\n" + indent += ' ' + invocation.proceed() + indent -= ' ' + lifecycleOutline += "$indent$type end ($name)\n" + } + } +} + +@Retention(RetentionPolicy.RUNTIME) +@ExtensionAnnotation(Interceptors.LifecycleRecorderAndContextTesterExtension) +@interface LifecycleTest { +} diff --git a/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__interceptors_are_called_in_the_correct_order_and_with_the_correct_context_information.txt b/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__interceptors_are_called_in_the_correct_order_and_with_the_correct_context_information.txt new file mode 100644 index 0000000000..ff0a05e2dc --- /dev/null +++ b/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__interceptors_are_called_in_the_correct_order_and_with_the_correct_context_information.txt @@ -0,0 +1,404 @@ +shared initializer start (SubSpec) + shared initializer method start (SuperSpec.$spock_initializeSharedFields()) + shared initializer method end (SuperSpec.$spock_initializeSharedFields()) + shared initializer method start (SubSpec.$spock_initializeSharedFields()) + shared initializer method end (SubSpec.$spock_initializeSharedFields()) +shared initializer end (SubSpec) +specification start (SubSpec) + setup spec start (SubSpec) + setup spec method start (SuperSpec.setupSpec()) + fixture method start (SuperSpec.setupSpec()) + fixture method end (SuperSpec.setupSpec()) + setup spec method end (SuperSpec.setupSpec()) + setup spec method start (SubSpec.setupSpec()) + fixture method start (SubSpec.setupSpec()) + fixture method end (SubSpec.setupSpec()) + setup spec method end (SubSpec.setupSpec()) + setup spec end (SubSpec) + feature start (SuperSpec.superFeature1) + initializer start (SuperSpec.superFeature1) + initializer method start (SuperSpec.superFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.superFeature1.$spock_initializeFields()) + initializer method start (SubSpec.superFeature1.$spock_initializeFields()) + initializer method end (SubSpec.superFeature1.$spock_initializeFields()) + initializer end (SuperSpec.superFeature1) + iteration start (SuperSpec.superFeature1[#0]) + setup start (SuperSpec.superFeature1[#0]) + setup method start (SuperSpec.superFeature1[#0].setup()) + fixture method start (SuperSpec.superFeature1[#0].setup()) + fixture method end (SuperSpec.superFeature1[#0].setup()) + setup method end (SuperSpec.superFeature1[#0].setup()) + setup method start (SubSpec.superFeature1[#0].setup()) + fixture method start (SubSpec.superFeature1[#0].setup()) + fixture method end (SubSpec.superFeature1[#0].setup()) + setup method end (SubSpec.superFeature1[#0].setup()) + setup end (SuperSpec.superFeature1[#0]) + feature method start (SuperSpec.superFeature1[#0].superFeature1()) + feature method end (SuperSpec.superFeature1[#0].superFeature1()) + cleanup start (SuperSpec.superFeature1[#0]) + cleanup method start (SubSpec.superFeature1[#0].cleanup()) + fixture method start (SubSpec.superFeature1[#0].cleanup()) + fixture method end (SubSpec.superFeature1[#0].cleanup()) + cleanup method end (SubSpec.superFeature1[#0].cleanup()) + cleanup method start (SuperSpec.superFeature1[#0].cleanup()) + fixture method start (SuperSpec.superFeature1[#0].cleanup()) + fixture method end (SuperSpec.superFeature1[#0].cleanup()) + cleanup method end (SuperSpec.superFeature1[#0].cleanup()) + cleanup end (SuperSpec.superFeature1[#0]) + iteration end (SuperSpec.superFeature1[#0]) + feature end (SuperSpec.superFeature1) + feature start (SuperSpec.superFeature2) + initializer start (SuperSpec.superFeature2) + initializer method start (SuperSpec.superFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.superFeature2.$spock_initializeFields()) + initializer method start (SubSpec.superFeature2.$spock_initializeFields()) + initializer method end (SubSpec.superFeature2.$spock_initializeFields()) + initializer end (SuperSpec.superFeature2) + iteration start (SuperSpec.superFeature2[#0]) + setup start (SuperSpec.superFeature2[#0]) + setup method start (SuperSpec.superFeature2[#0].setup()) + fixture method start (SuperSpec.superFeature2[#0].setup()) + fixture method end (SuperSpec.superFeature2[#0].setup()) + setup method end (SuperSpec.superFeature2[#0].setup()) + setup method start (SubSpec.superFeature2[#0].setup()) + fixture method start (SubSpec.superFeature2[#0].setup()) + fixture method end (SubSpec.superFeature2[#0].setup()) + setup method end (SubSpec.superFeature2[#0].setup()) + setup end (SuperSpec.superFeature2[#0]) + feature method start (SuperSpec.superFeature2[#0].superFeature2()) + feature method end (SuperSpec.superFeature2[#0].superFeature2()) + cleanup start (SuperSpec.superFeature2[#0]) + cleanup method start (SubSpec.superFeature2[#0].cleanup()) + fixture method start (SubSpec.superFeature2[#0].cleanup()) + fixture method end (SubSpec.superFeature2[#0].cleanup()) + cleanup method end (SubSpec.superFeature2[#0].cleanup()) + cleanup method start (SuperSpec.superFeature2[#0].cleanup()) + fixture method start (SuperSpec.superFeature2[#0].cleanup()) + fixture method end (SuperSpec.superFeature2[#0].cleanup()) + cleanup method end (SuperSpec.superFeature2[#0].cleanup()) + cleanup end (SuperSpec.superFeature2[#0]) + iteration end (SuperSpec.superFeature2[#0]) + feature end (SuperSpec.superFeature2) + feature start (SuperSpec.superDataFeature1) + initializer start (SuperSpec.superDataFeature1) + initializer method start (SuperSpec.superDataFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.superDataFeature1.$spock_initializeFields()) + initializer method start (SubSpec.superDataFeature1.$spock_initializeFields()) + initializer method end (SubSpec.superDataFeature1.$spock_initializeFields()) + initializer end (SuperSpec.superDataFeature1) + iteration start (SuperSpec.superDataFeature1[#0]) + setup start (SuperSpec.superDataFeature1[#0]) + setup method start (SuperSpec.superDataFeature1[#0].setup()) + fixture method start (SuperSpec.superDataFeature1[#0].setup()) + fixture method end (SuperSpec.superDataFeature1[#0].setup()) + setup method end (SuperSpec.superDataFeature1[#0].setup()) + setup method start (SubSpec.superDataFeature1[#0].setup()) + fixture method start (SubSpec.superDataFeature1[#0].setup()) + fixture method end (SubSpec.superDataFeature1[#0].setup()) + setup method end (SubSpec.superDataFeature1[#0].setup()) + setup end (SuperSpec.superDataFeature1[#0]) + feature method start (SuperSpec.superDataFeature1[#0].superDataFeature1()) + feature method end (SuperSpec.superDataFeature1[#0].superDataFeature1()) + cleanup start (SuperSpec.superDataFeature1[#0]) + cleanup method start (SubSpec.superDataFeature1[#0].cleanup()) + fixture method start (SubSpec.superDataFeature1[#0].cleanup()) + fixture method end (SubSpec.superDataFeature1[#0].cleanup()) + cleanup method end (SubSpec.superDataFeature1[#0].cleanup()) + cleanup method start (SuperSpec.superDataFeature1[#0].cleanup()) + fixture method start (SuperSpec.superDataFeature1[#0].cleanup()) + fixture method end (SuperSpec.superDataFeature1[#0].cleanup()) + cleanup method end (SuperSpec.superDataFeature1[#0].cleanup()) + cleanup end (SuperSpec.superDataFeature1[#0]) + iteration end (SuperSpec.superDataFeature1[#0]) + initializer start (SuperSpec.superDataFeature1) + initializer method start (SuperSpec.superDataFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.superDataFeature1.$spock_initializeFields()) + initializer method start (SubSpec.superDataFeature1.$spock_initializeFields()) + initializer method end (SubSpec.superDataFeature1.$spock_initializeFields()) + initializer end (SuperSpec.superDataFeature1) + iteration start (SuperSpec.superDataFeature1[#1]) + setup start (SuperSpec.superDataFeature1[#1]) + setup method start (SuperSpec.superDataFeature1[#1].setup()) + fixture method start (SuperSpec.superDataFeature1[#1].setup()) + fixture method end (SuperSpec.superDataFeature1[#1].setup()) + setup method end (SuperSpec.superDataFeature1[#1].setup()) + setup method start (SubSpec.superDataFeature1[#1].setup()) + fixture method start (SubSpec.superDataFeature1[#1].setup()) + fixture method end (SubSpec.superDataFeature1[#1].setup()) + setup method end (SubSpec.superDataFeature1[#1].setup()) + setup end (SuperSpec.superDataFeature1[#1]) + feature method start (SuperSpec.superDataFeature1[#1].superDataFeature1()) + feature method end (SuperSpec.superDataFeature1[#1].superDataFeature1()) + cleanup start (SuperSpec.superDataFeature1[#1]) + cleanup method start (SubSpec.superDataFeature1[#1].cleanup()) + fixture method start (SubSpec.superDataFeature1[#1].cleanup()) + fixture method end (SubSpec.superDataFeature1[#1].cleanup()) + cleanup method end (SubSpec.superDataFeature1[#1].cleanup()) + cleanup method start (SuperSpec.superDataFeature1[#1].cleanup()) + fixture method start (SuperSpec.superDataFeature1[#1].cleanup()) + fixture method end (SuperSpec.superDataFeature1[#1].cleanup()) + cleanup method end (SuperSpec.superDataFeature1[#1].cleanup()) + cleanup end (SuperSpec.superDataFeature1[#1]) + iteration end (SuperSpec.superDataFeature1[#1]) + feature end (SuperSpec.superDataFeature1) + feature start (SuperSpec.superDataFeature2) + initializer start (SuperSpec.superDataFeature2) + initializer method start (SuperSpec.superDataFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.superDataFeature2.$spock_initializeFields()) + initializer method start (SubSpec.superDataFeature2.$spock_initializeFields()) + initializer method end (SubSpec.superDataFeature2.$spock_initializeFields()) + initializer end (SuperSpec.superDataFeature2) + iteration start (SuperSpec.superDataFeature2[#0]) + setup start (SuperSpec.superDataFeature2[#0]) + setup method start (SuperSpec.superDataFeature2[#0].setup()) + fixture method start (SuperSpec.superDataFeature2[#0].setup()) + fixture method end (SuperSpec.superDataFeature2[#0].setup()) + setup method end (SuperSpec.superDataFeature2[#0].setup()) + setup method start (SubSpec.superDataFeature2[#0].setup()) + fixture method start (SubSpec.superDataFeature2[#0].setup()) + fixture method end (SubSpec.superDataFeature2[#0].setup()) + setup method end (SubSpec.superDataFeature2[#0].setup()) + setup end (SuperSpec.superDataFeature2[#0]) + feature method start (SuperSpec.superDataFeature2[#0].superDataFeature2()) + feature method end (SuperSpec.superDataFeature2[#0].superDataFeature2()) + cleanup start (SuperSpec.superDataFeature2[#0]) + cleanup method start (SubSpec.superDataFeature2[#0].cleanup()) + fixture method start (SubSpec.superDataFeature2[#0].cleanup()) + fixture method end (SubSpec.superDataFeature2[#0].cleanup()) + cleanup method end (SubSpec.superDataFeature2[#0].cleanup()) + cleanup method start (SuperSpec.superDataFeature2[#0].cleanup()) + fixture method start (SuperSpec.superDataFeature2[#0].cleanup()) + fixture method end (SuperSpec.superDataFeature2[#0].cleanup()) + cleanup method end (SuperSpec.superDataFeature2[#0].cleanup()) + cleanup end (SuperSpec.superDataFeature2[#0]) + iteration end (SuperSpec.superDataFeature2[#0]) + initializer start (SuperSpec.superDataFeature2) + initializer method start (SuperSpec.superDataFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.superDataFeature2.$spock_initializeFields()) + initializer method start (SubSpec.superDataFeature2.$spock_initializeFields()) + initializer method end (SubSpec.superDataFeature2.$spock_initializeFields()) + initializer end (SuperSpec.superDataFeature2) + iteration start (SuperSpec.superDataFeature2[#1]) + setup start (SuperSpec.superDataFeature2[#1]) + setup method start (SuperSpec.superDataFeature2[#1].setup()) + fixture method start (SuperSpec.superDataFeature2[#1].setup()) + fixture method end (SuperSpec.superDataFeature2[#1].setup()) + setup method end (SuperSpec.superDataFeature2[#1].setup()) + setup method start (SubSpec.superDataFeature2[#1].setup()) + fixture method start (SubSpec.superDataFeature2[#1].setup()) + fixture method end (SubSpec.superDataFeature2[#1].setup()) + setup method end (SubSpec.superDataFeature2[#1].setup()) + setup end (SuperSpec.superDataFeature2[#1]) + feature method start (SuperSpec.superDataFeature2[#1].superDataFeature2()) + feature method end (SuperSpec.superDataFeature2[#1].superDataFeature2()) + cleanup start (SuperSpec.superDataFeature2[#1]) + cleanup method start (SubSpec.superDataFeature2[#1].cleanup()) + fixture method start (SubSpec.superDataFeature2[#1].cleanup()) + fixture method end (SubSpec.superDataFeature2[#1].cleanup()) + cleanup method end (SubSpec.superDataFeature2[#1].cleanup()) + cleanup method start (SuperSpec.superDataFeature2[#1].cleanup()) + fixture method start (SuperSpec.superDataFeature2[#1].cleanup()) + fixture method end (SuperSpec.superDataFeature2[#1].cleanup()) + cleanup method end (SuperSpec.superDataFeature2[#1].cleanup()) + cleanup end (SuperSpec.superDataFeature2[#1]) + iteration end (SuperSpec.superDataFeature2[#1]) + feature end (SuperSpec.superDataFeature2) + feature start (SubSpec.subFeature1) + initializer start (SubSpec.subFeature1) + initializer method start (SuperSpec.subFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.subFeature1.$spock_initializeFields()) + initializer method start (SubSpec.subFeature1.$spock_initializeFields()) + initializer method end (SubSpec.subFeature1.$spock_initializeFields()) + initializer end (SubSpec.subFeature1) + iteration start (SubSpec.subFeature1[#0]) + setup start (SubSpec.subFeature1[#0]) + setup method start (SuperSpec.subFeature1[#0].setup()) + fixture method start (SuperSpec.subFeature1[#0].setup()) + fixture method end (SuperSpec.subFeature1[#0].setup()) + setup method end (SuperSpec.subFeature1[#0].setup()) + setup method start (SubSpec.subFeature1[#0].setup()) + fixture method start (SubSpec.subFeature1[#0].setup()) + fixture method end (SubSpec.subFeature1[#0].setup()) + setup method end (SubSpec.subFeature1[#0].setup()) + setup end (SubSpec.subFeature1[#0]) + feature method start (SubSpec.subFeature1[#0].subFeature1()) + feature method end (SubSpec.subFeature1[#0].subFeature1()) + cleanup start (SubSpec.subFeature1[#0]) + cleanup method start (SubSpec.subFeature1[#0].cleanup()) + fixture method start (SubSpec.subFeature1[#0].cleanup()) + fixture method end (SubSpec.subFeature1[#0].cleanup()) + cleanup method end (SubSpec.subFeature1[#0].cleanup()) + cleanup method start (SuperSpec.subFeature1[#0].cleanup()) + fixture method start (SuperSpec.subFeature1[#0].cleanup()) + fixture method end (SuperSpec.subFeature1[#0].cleanup()) + cleanup method end (SuperSpec.subFeature1[#0].cleanup()) + cleanup end (SubSpec.subFeature1[#0]) + iteration end (SubSpec.subFeature1[#0]) + feature end (SubSpec.subFeature1) + feature start (SubSpec.subFeature2) + initializer start (SubSpec.subFeature2) + initializer method start (SuperSpec.subFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.subFeature2.$spock_initializeFields()) + initializer method start (SubSpec.subFeature2.$spock_initializeFields()) + initializer method end (SubSpec.subFeature2.$spock_initializeFields()) + initializer end (SubSpec.subFeature2) + iteration start (SubSpec.subFeature2[#0]) + setup start (SubSpec.subFeature2[#0]) + setup method start (SuperSpec.subFeature2[#0].setup()) + fixture method start (SuperSpec.subFeature2[#0].setup()) + fixture method end (SuperSpec.subFeature2[#0].setup()) + setup method end (SuperSpec.subFeature2[#0].setup()) + setup method start (SubSpec.subFeature2[#0].setup()) + fixture method start (SubSpec.subFeature2[#0].setup()) + fixture method end (SubSpec.subFeature2[#0].setup()) + setup method end (SubSpec.subFeature2[#0].setup()) + setup end (SubSpec.subFeature2[#0]) + feature method start (SubSpec.subFeature2[#0].subFeature2()) + feature method end (SubSpec.subFeature2[#0].subFeature2()) + cleanup start (SubSpec.subFeature2[#0]) + cleanup method start (SubSpec.subFeature2[#0].cleanup()) + fixture method start (SubSpec.subFeature2[#0].cleanup()) + fixture method end (SubSpec.subFeature2[#0].cleanup()) + cleanup method end (SubSpec.subFeature2[#0].cleanup()) + cleanup method start (SuperSpec.subFeature2[#0].cleanup()) + fixture method start (SuperSpec.subFeature2[#0].cleanup()) + fixture method end (SuperSpec.subFeature2[#0].cleanup()) + cleanup method end (SuperSpec.subFeature2[#0].cleanup()) + cleanup end (SubSpec.subFeature2[#0]) + iteration end (SubSpec.subFeature2[#0]) + feature end (SubSpec.subFeature2) + feature start (SubSpec.subDataFeature1) + initializer start (SubSpec.subDataFeature1) + initializer method start (SuperSpec.subDataFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.subDataFeature1.$spock_initializeFields()) + initializer method start (SubSpec.subDataFeature1.$spock_initializeFields()) + initializer method end (SubSpec.subDataFeature1.$spock_initializeFields()) + initializer end (SubSpec.subDataFeature1) + iteration start (SubSpec.subDataFeature1[#0]) + setup start (SubSpec.subDataFeature1[#0]) + setup method start (SuperSpec.subDataFeature1[#0].setup()) + fixture method start (SuperSpec.subDataFeature1[#0].setup()) + fixture method end (SuperSpec.subDataFeature1[#0].setup()) + setup method end (SuperSpec.subDataFeature1[#0].setup()) + setup method start (SubSpec.subDataFeature1[#0].setup()) + fixture method start (SubSpec.subDataFeature1[#0].setup()) + fixture method end (SubSpec.subDataFeature1[#0].setup()) + setup method end (SubSpec.subDataFeature1[#0].setup()) + setup end (SubSpec.subDataFeature1[#0]) + feature method start (SubSpec.subDataFeature1[#0].subDataFeature1()) + feature method end (SubSpec.subDataFeature1[#0].subDataFeature1()) + cleanup start (SubSpec.subDataFeature1[#0]) + cleanup method start (SubSpec.subDataFeature1[#0].cleanup()) + fixture method start (SubSpec.subDataFeature1[#0].cleanup()) + fixture method end (SubSpec.subDataFeature1[#0].cleanup()) + cleanup method end (SubSpec.subDataFeature1[#0].cleanup()) + cleanup method start (SuperSpec.subDataFeature1[#0].cleanup()) + fixture method start (SuperSpec.subDataFeature1[#0].cleanup()) + fixture method end (SuperSpec.subDataFeature1[#0].cleanup()) + cleanup method end (SuperSpec.subDataFeature1[#0].cleanup()) + cleanup end (SubSpec.subDataFeature1[#0]) + iteration end (SubSpec.subDataFeature1[#0]) + initializer start (SubSpec.subDataFeature1) + initializer method start (SuperSpec.subDataFeature1.$spock_initializeFields()) + initializer method end (SuperSpec.subDataFeature1.$spock_initializeFields()) + initializer method start (SubSpec.subDataFeature1.$spock_initializeFields()) + initializer method end (SubSpec.subDataFeature1.$spock_initializeFields()) + initializer end (SubSpec.subDataFeature1) + iteration start (SubSpec.subDataFeature1[#1]) + setup start (SubSpec.subDataFeature1[#1]) + setup method start (SuperSpec.subDataFeature1[#1].setup()) + fixture method start (SuperSpec.subDataFeature1[#1].setup()) + fixture method end (SuperSpec.subDataFeature1[#1].setup()) + setup method end (SuperSpec.subDataFeature1[#1].setup()) + setup method start (SubSpec.subDataFeature1[#1].setup()) + fixture method start (SubSpec.subDataFeature1[#1].setup()) + fixture method end (SubSpec.subDataFeature1[#1].setup()) + setup method end (SubSpec.subDataFeature1[#1].setup()) + setup end (SubSpec.subDataFeature1[#1]) + feature method start (SubSpec.subDataFeature1[#1].subDataFeature1()) + feature method end (SubSpec.subDataFeature1[#1].subDataFeature1()) + cleanup start (SubSpec.subDataFeature1[#1]) + cleanup method start (SubSpec.subDataFeature1[#1].cleanup()) + fixture method start (SubSpec.subDataFeature1[#1].cleanup()) + fixture method end (SubSpec.subDataFeature1[#1].cleanup()) + cleanup method end (SubSpec.subDataFeature1[#1].cleanup()) + cleanup method start (SuperSpec.subDataFeature1[#1].cleanup()) + fixture method start (SuperSpec.subDataFeature1[#1].cleanup()) + fixture method end (SuperSpec.subDataFeature1[#1].cleanup()) + cleanup method end (SuperSpec.subDataFeature1[#1].cleanup()) + cleanup end (SubSpec.subDataFeature1[#1]) + iteration end (SubSpec.subDataFeature1[#1]) + feature end (SubSpec.subDataFeature1) + feature start (SubSpec.subDataFeature2) + initializer start (SubSpec.subDataFeature2) + initializer method start (SuperSpec.subDataFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.subDataFeature2.$spock_initializeFields()) + initializer method start (SubSpec.subDataFeature2.$spock_initializeFields()) + initializer method end (SubSpec.subDataFeature2.$spock_initializeFields()) + initializer end (SubSpec.subDataFeature2) + iteration start (SubSpec.subDataFeature2[#0]) + setup start (SubSpec.subDataFeature2[#0]) + setup method start (SuperSpec.subDataFeature2[#0].setup()) + fixture method start (SuperSpec.subDataFeature2[#0].setup()) + fixture method end (SuperSpec.subDataFeature2[#0].setup()) + setup method end (SuperSpec.subDataFeature2[#0].setup()) + setup method start (SubSpec.subDataFeature2[#0].setup()) + fixture method start (SubSpec.subDataFeature2[#0].setup()) + fixture method end (SubSpec.subDataFeature2[#0].setup()) + setup method end (SubSpec.subDataFeature2[#0].setup()) + setup end (SubSpec.subDataFeature2[#0]) + feature method start (SubSpec.subDataFeature2[#0].subDataFeature2()) + feature method end (SubSpec.subDataFeature2[#0].subDataFeature2()) + cleanup start (SubSpec.subDataFeature2[#0]) + cleanup method start (SubSpec.subDataFeature2[#0].cleanup()) + fixture method start (SubSpec.subDataFeature2[#0].cleanup()) + fixture method end (SubSpec.subDataFeature2[#0].cleanup()) + cleanup method end (SubSpec.subDataFeature2[#0].cleanup()) + cleanup method start (SuperSpec.subDataFeature2[#0].cleanup()) + fixture method start (SuperSpec.subDataFeature2[#0].cleanup()) + fixture method end (SuperSpec.subDataFeature2[#0].cleanup()) + cleanup method end (SuperSpec.subDataFeature2[#0].cleanup()) + cleanup end (SubSpec.subDataFeature2[#0]) + iteration end (SubSpec.subDataFeature2[#0]) + initializer start (SubSpec.subDataFeature2) + initializer method start (SuperSpec.subDataFeature2.$spock_initializeFields()) + initializer method end (SuperSpec.subDataFeature2.$spock_initializeFields()) + initializer method start (SubSpec.subDataFeature2.$spock_initializeFields()) + initializer method end (SubSpec.subDataFeature2.$spock_initializeFields()) + initializer end (SubSpec.subDataFeature2) + iteration start (SubSpec.subDataFeature2[#1]) + setup start (SubSpec.subDataFeature2[#1]) + setup method start (SuperSpec.subDataFeature2[#1].setup()) + fixture method start (SuperSpec.subDataFeature2[#1].setup()) + fixture method end (SuperSpec.subDataFeature2[#1].setup()) + setup method end (SuperSpec.subDataFeature2[#1].setup()) + setup method start (SubSpec.subDataFeature2[#1].setup()) + fixture method start (SubSpec.subDataFeature2[#1].setup()) + fixture method end (SubSpec.subDataFeature2[#1].setup()) + setup method end (SubSpec.subDataFeature2[#1].setup()) + setup end (SubSpec.subDataFeature2[#1]) + feature method start (SubSpec.subDataFeature2[#1].subDataFeature2()) + feature method end (SubSpec.subDataFeature2[#1].subDataFeature2()) + cleanup start (SubSpec.subDataFeature2[#1]) + cleanup method start (SubSpec.subDataFeature2[#1].cleanup()) + fixture method start (SubSpec.subDataFeature2[#1].cleanup()) + fixture method end (SubSpec.subDataFeature2[#1].cleanup()) + cleanup method end (SubSpec.subDataFeature2[#1].cleanup()) + cleanup method start (SuperSpec.subDataFeature2[#1].cleanup()) + fixture method start (SuperSpec.subDataFeature2[#1].cleanup()) + fixture method end (SuperSpec.subDataFeature2[#1].cleanup()) + cleanup method end (SuperSpec.subDataFeature2[#1].cleanup()) + cleanup end (SubSpec.subDataFeature2[#1]) + iteration end (SubSpec.subDataFeature2[#1]) + feature end (SubSpec.subDataFeature2) + cleanup spec start (SubSpec) + cleanup spec method start (SubSpec.cleanupSpec()) + fixture method start (SubSpec.cleanupSpec()) + fixture method end (SubSpec.cleanupSpec()) + cleanup spec method end (SubSpec.cleanupSpec()) + cleanup spec method start (SuperSpec.cleanupSpec()) + fixture method start (SuperSpec.cleanupSpec()) + fixture method end (SuperSpec.cleanupSpec()) + cleanup spec method end (SuperSpec.cleanupSpec()) + cleanup spec end (SubSpec) +specification end (SubSpec) diff --git a/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__non_method_interceptors_are_called_even_without_the_respective_method.txt b/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__non_method_interceptors_are_called_even_without_the_respective_method.txt new file mode 100644 index 0000000000..86b81307ea --- /dev/null +++ b/spock-specs/src/test/resources/org/spockframework/smoke/Interceptors__non_method_interceptors_are_called_even_without_the_respective_method.txt @@ -0,0 +1,42 @@ +shared initializer start (FooSpec) +shared initializer end (FooSpec) +specification start (FooSpec) + setup spec start (FooSpec) + setup spec end (FooSpec) + feature start (FooSpec.foo) + initializer start (FooSpec.foo) + initializer end (FooSpec.foo) + iteration start (FooSpec.foo[#0]) + setup start (FooSpec.foo[#0]) + setup end (FooSpec.foo[#0]) + feature method start (FooSpec.foo[#0].foo()) + feature method end (FooSpec.foo[#0].foo()) + cleanup start (FooSpec.foo[#0]) + cleanup end (FooSpec.foo[#0]) + iteration end (FooSpec.foo[#0]) + feature end (FooSpec.foo) + feature start (FooSpec.bar) + initializer start (FooSpec.bar) + initializer end (FooSpec.bar) + iteration start (FooSpec.bar[#0]) + setup start (FooSpec.bar[#0]) + setup end (FooSpec.bar[#0]) + feature method start (FooSpec.bar[#0].bar()) + feature method end (FooSpec.bar[#0].bar()) + cleanup start (FooSpec.bar[#0]) + cleanup end (FooSpec.bar[#0]) + iteration end (FooSpec.bar[#0]) + initializer start (FooSpec.bar) + initializer end (FooSpec.bar) + iteration start (FooSpec.bar[#1]) + setup start (FooSpec.bar[#1]) + setup end (FooSpec.bar[#1]) + feature method start (FooSpec.bar[#1].bar()) + feature method end (FooSpec.bar[#1].bar()) + cleanup start (FooSpec.bar[#1]) + cleanup end (FooSpec.bar[#1]) + iteration end (FooSpec.bar[#1]) + feature end (FooSpec.bar) + cleanup spec start (FooSpec) + cleanup spec end (FooSpec) +specification end (FooSpec)