From 5d18c85e4ecf6ba4a4c13b02af0b5ad10481348f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 2 Jun 2026 18:25:55 +0200 Subject: [PATCH 1/3] Extend the top interaction scope to cleanup methods --- docs/interaction_based_testing.adoc | 2 +- docs/release_notes.adoc | 6 ++ .../spockframework/compiler/AstNodeCache.java | 3 + .../spockframework/compiler/SpecRewriter.java | 2 +- .../mock/TooFewInvocationsError.java | 2 +- .../mock/runtime/MockController.java | 10 ++- .../mock/GlobalInteractionsInCleanup.groovy | 62 +++++++++++++++++++ ...are_used_in_AST_transformation-groovy4.txt | 2 +- ...are_used_in_AST_transformation-groovy5.txt | 2 +- ...e_types_are_used_in_AST_transformation.txt | 2 +- ...ceFeatureBody_can_render_everything.groovy | 2 +- ...n_render_everything__Groovy_4_0_2__.groovy | 2 +- ...thods_and_its_annotation_by_default.groovy | 2 +- ...ers_and_their_annotation_by_default.groovy | 2 +- ...servable_blocks_with_GString_labels.groovy | 2 +- ...observable_blocks_with_empty_labels.groovy | 2 +- ...vable_blocks_with_labels_and_blocks.groovy | 2 +- ...rite_keeps_correct_method_reference.groovy | 2 +- ...rence_for_multi_assignments-groovy5.groovy | 2 +- ...hod_reference_for_multi_assignments.groovy | 2 +- .../DataAstSpec/multi_parameterization.groovy | 2 +- .../nested_multi_parameterization.groovy | 2 +- ...ith__separators_can_be_combined-[0].groovy | 2 +- ...ith__separators_can_be_combined-[1].groovy | 2 +- ...ith__separators_can_be_combined-[2].groovy | 2 +- ...filter_block_becomes_its_own_method.groovy | 2 +- ...e_in_a_cell_multiple_times_compiles.groovy | 2 +- ...tionsAsSet_is_transformed_correctly.groovy | 2 +- ...InAnyOrder_is_transformed_correctly.groovy | 2 +- ...onditions_are_transformed_correctly.groovy | 2 +- ...onditions_are_transformed_correctly.groovy | 2 +- ...ilt_in_method_as_explicit_condition.groovy | 2 +- ...ilt_in_method_as_implicit_condition.groovy | 2 +- ...ndition_method__conditionMethod-[0].groovy | 2 +- ...ndition_method__conditionMethod-[1].groovy | 2 +- ...ndition_method__conditionMethod-[2].groovy | 2 +- ..._conditionMethod_with_exception-[0].groovy | 2 +- ..._conditionMethod_with_exception-[1].groovy | 2 +- ..._conditionMethod_with_exception-[2].groovy | 2 +- ...itionMethod_with_only_exception-[0].groovy | 2 +- ...itionMethod_with_only_exception-[1].groovy | 2 +- ...itionMethod_with_only_exception-[2].groovy | 2 +- ...ndition_method__conditionMethod-[0].groovy | 2 +- ...ndition_method__conditionMethod-[1].groovy | 2 +- ...ndition_method__conditionMethod-[2].groovy | 2 +- ..._conditionMethod_with_exception-[0].groovy | 2 +- ..._conditionMethod_with_exception-[1].groovy | 2 +- ..._conditionMethod_with_exception-[2].groovy | 2 +- ...itionMethod_with_only_exception-[0].groovy | 2 +- ...itionMethod_with_only_exception-[1].groovy | 2 +- ...itionMethod_with_only_exception-[2].groovy | 2 +- ...rite_keeps_correct_method_reference.groovy | 2 +- ...rence_for_multi_assignments-groovy5.groovy | 2 +- ...hod_reference_for_multi_assignments.groovy | 2 +- ...eclarations_stay_unchanged_in_specs.groovy | 2 +- ...forms_conditions_in_private_methods.groovy | 2 +- ...eclarations_stay_unchanged_in_specs.groovy | 2 +- ...forms_conditions_in_private_methods.groovy | 2 +- .../MocksAstSpec/simple_interaction.groovy | 2 +- ...er_variable_in_data_provider_method.groovy | 2 +- ...r_variable_in_data_processor_method.groovy | 2 +- 61 files changed, 137 insertions(+), 58 deletions(-) create mode 100644 spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy diff --git a/docs/interaction_based_testing.adoc b/docs/interaction_based_testing.adoc index 89dc056dbc..cbb3cfbf6b 100644 --- a/docs/interaction_based_testing.adoc +++ b/docs/interaction_based_testing.adoc @@ -444,7 +444,7 @@ This makes sure that `subscriber` receives `"message1"` during execution of the and `"message2"` during execution of the second `when:` block. Interactions declared outside a `then:` block are active from their declaration until the end of the -containing feature method. +containing feature method plus an eventually existing `cleanup` method. Interactions are always scoped to a particular feature method. Hence they cannot be declared in a static method, `setupSpec` method, or `cleanupSpec` method. Likewise, mock objects should not be stored in static or `@Shared` diff --git a/docs/release_notes.adoc b/docs/release_notes.adoc index 3241d6b7bc..f9c76b6c53 100644 --- a/docs/release_notes.adoc +++ b/docs/release_notes.adoc @@ -25,6 +25,12 @@ include::include.adoc[] === Breaking Changes * Mock/Stub checks on `Comparable` with `T` being something other than `Object` now compare using the java identity hash code instead of always being equal spockIssue:2352[] +* Interactions outside a `then:` block are now still active in an eventually existing `cleanup` method. + If the interaction contains a lower cardinality, this is still checked at the end of the feature method. + Upper cardinality is still relevant in the `cleanup` method, so could cause test failures where previously simply the default response of the mock object was used without cardinality check and could now cause previously working tests to fail. + This enables `cleanup` methods to get stubbed responses from mock objects which previously was only possible by using a custom default response. + If an interaction with stubbed response is present, the default response is also no longer used in the `cleanup` method because the interaction's stubbed response is used now, which could also cause existing tests to fail. + spockIssue:616[] == 2.4 (2025-12-11) diff --git a/spock-core/src/main/java/org/spockframework/compiler/AstNodeCache.java b/spock-core/src/main/java/org/spockframework/compiler/AstNodeCache.java index c71f3c986e..e476728030 100644 --- a/spock-core/src/main/java/org/spockframework/compiler/AstNodeCache.java +++ b/spock-core/src/main/java/org/spockframework/compiler/AstNodeCache.java @@ -110,6 +110,9 @@ public class AstNodeCache { public final MethodNode MockController_LeaveScope = MockController.getDeclaredMethods(org.spockframework.mock.runtime.MockController.LEAVE_SCOPE).get(0); + public final MethodNode MockController_VerifyLastScope = + MockController.getDeclaredMethods(org.spockframework.mock.runtime.MockController.VERIFY_LAST_SCOPE).get(0); + public final MethodNode SpecificationContext_GetMockController = SpecificationContext.getDeclaredMethods(org.spockframework.runtime.SpecificationContext.GET_MOCK_CONTROLLER).get(0); diff --git a/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java b/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java index 1911fe7c72..8be9eaead2 100644 --- a/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java +++ b/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java @@ -410,7 +410,7 @@ public void visitMethodAgain(Method method) { // for global required interactions if (method instanceof FeatureMethod) { - method.getStatements().add(createMockControllerCall(nodeCache.MockController_LeaveScope)); + method.getStatements().add(createMockControllerCall(nodeCache.MockController_VerifyLastScope)); } if (method instanceof VerifyAllMethod) { diff --git a/spock-core/src/main/java/org/spockframework/mock/TooFewInvocationsError.java b/spock-core/src/main/java/org/spockframework/mock/TooFewInvocationsError.java index 1bee5fd09a..5b91e87967 100644 --- a/spock-core/src/main/java/org/spockframework/mock/TooFewInvocationsError.java +++ b/spock-core/src/main/java/org/spockframework/mock/TooFewInvocationsError.java @@ -37,7 +37,7 @@ public TooFewInvocationsError(List interactions, List 0); this.interactions = interactions; - this.unmatchedInvocations = unmatchedInvocations; + this.unmatchedInvocations = new ArrayList<>(unmatchedInvocations); } @Override diff --git a/spock-core/src/main/java/org/spockframework/mock/runtime/MockController.java b/spock-core/src/main/java/org/spockframework/mock/runtime/MockController.java index e49c625f60..5a20714a17 100644 --- a/spock-core/src/main/java/org/spockframework/mock/runtime/MockController.java +++ b/spock-core/src/main/java/org/spockframework/mock/runtime/MockController.java @@ -17,7 +17,7 @@ package org.spockframework.mock.runtime; import org.spockframework.mock.*; -import org.spockframework.util.Checks; +import org.spockframework.util.Assert; import org.spockframework.util.ExceptionUtil; import java.util.*; @@ -110,6 +110,14 @@ public synchronized void leaveScope() { scope.verifyInteractions(); } + public static final String VERIFY_LAST_SCOPE = "verifyLastScope"; + + public synchronized void verifyLastScope() { + throwAnyPreviousError(); + Assert.that(scopes.size() == 1, () -> "There should be exactly one scope left, but there were " + scopes.size()); + scopes.getFirst().verifyInteractions(); + } + private void throwAnyPreviousError() { if (!errors.isEmpty()) throw errors.get(0); } diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy new file mode 100644 index 0000000000..faefbfe30a --- /dev/null +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy @@ -0,0 +1,62 @@ +/* + * Copyright 2026 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.mock + +import org.spockframework.runtime.ConditionNotSatisfiedError +import spock.lang.FailsWith +import spock.lang.Issue +import spock.lang.Specification + +import java.util.function.Function + +@Issue("https://github.com/spockframework/spock/issues/616") +class GlobalInteractionsInCleanup extends Specification { + def mock = Mock(Function) + def mock2 = Mock(Function) { + apply("a") >> { "c" } + } + def mock3 = Mock(Function) + + def setup() { + mock.apply("a") >> { "b" } + } + + def cleanup() { + verifyAll { + mock.apply("a") == "b" + mock2.apply("a") == "c" + mock3.apply("a") == "d" + } + } + + def "run a successful test"() { + given: + mock3.apply("a") >> { "d" } + + expect: + true + } + + @FailsWith(ConditionNotSatisfiedError) + def "run a failing test"() { + given: + mock3.apply("a") >> { "d" } + + expect: + false + } +} diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy4.txt b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy4.txt index 40502c0621..032f2c0b60 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy4.txt +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy4.txt @@ -208,7 +208,7 @@ public class apackage/TestSpec extends spock/lang/Specification implements groov "()", 0 ] - INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.leaveScope ()V + INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.verifyLastScope ()V ACONST_NULL POP L18 diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy5.txt b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy5.txt index e814a4c5a0..497c8708db 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy5.txt +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation-groovy5.txt @@ -184,7 +184,7 @@ public class apackage/TestSpec extends spock/lang/Specification implements groov "()", 0 ] - INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.leaveScope ()V + INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.verifyLastScope ()V L18 LINENUMBER 9 L18 RETURN diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation.txt b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation.txt index 0ef9f26521..c075f472d1 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation.txt +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/Primitive_types_are_used_in_AST_transformation.txt @@ -181,7 +181,7 @@ public class apackage/TestSpec extends spock/lang/Specification implements groov LDC Lorg/spockframework/mock/runtime/MockController;.class INVOKESTATIC org/codehaus/groovy/runtime/ScriptBytecodeAdapter.castToType (Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object; CHECKCAST org/spockframework/mock/runtime/MockController - INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.leaveScope ()V + INVOKEVIRTUAL org/spockframework/mock/runtime/MockController.verifyLastScope ()V ACONST_NULL POP L18 diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything.groovy index 7ffba1c2db..48c8867ad5 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything.groovy @@ -10,7 +10,7 @@ public class apackage.ASpec extends spock.lang.Specification { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 0) java.lang.Object nothing = null org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything__Groovy_4_0_2__.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything__Groovy_4_0_2__.groovy index fd88bc3283..2c67706e02 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything__Groovy_4_0_2__.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_can_render_everything__Groovy_4_0_2__.groovy @@ -10,7 +10,7 @@ public class apackage.ASpec extends spock.lang.Specification implements groovy.l org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 0) java.lang.Object nothing = null org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_renders_only_methods_and_its_annotation_by_default.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_renders_only_methods_and_its_annotation_by_default.groovy index dd6b84996a..d4d2379369 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_renders_only_methods_and_its_annotation_by_default.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceFeatureBody_renders_only_methods_and_its_annotation_by_default.groovy @@ -9,7 +9,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 0) java.lang.Object nothing = null org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceSpecBody_renders_only_methods__fields__properties__object_initializers_and_their_annotation_by_default.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceSpecBody_renders_only_methods__fields__properties__object_initializers_and_their_annotation_by_default.groovy index 6e4e7d6fae..d7166674c0 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceSpecBody_renders_only_methods__fields__properties__object_initializers_and_their_annotation_by_default.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/AstSpec/astToSourceSpecBody_renders_only_methods__fields__properties__object_initializers_and_their_annotation_by_default.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 0) java.lang.Object nothing = null org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_GString_labels.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_GString_labels.groovy index 18d9bfa43d..9b2c04dfac 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_GString_labels.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_GString_labels.groovy @@ -29,7 +29,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, '\"then \${idx++}\"', 5, 11, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 3) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_empty_labels.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_empty_labels.groovy index 88246b1939..896d1e8250 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_empty_labels.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_empty_labels.groovy @@ -43,7 +43,7 @@ public void $spock_feature_0_0() { } } } - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_labels_and_blocks.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_labels_and_blocks.groovy index b0915d67f6..880b11980f 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_labels_and_blocks.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/BlocksAst/all_observable_blocks_with_labels_and_blocks.groovy @@ -45,7 +45,7 @@ public void $spock_feature_0_0() { } } } - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference.groovy index f89c4c10a6..76b23433ca 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference.groovy @@ -51,7 +51,7 @@ public void $spock_feature_0_0() { } } } - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy index 5cf028c956..191532f9f3 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy @@ -51,7 +51,7 @@ public void $spock_feature_0_0() { } } } - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy index 5cf028c956..191532f9f3 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/CleanupBlocksAstSpec/cleanup_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy @@ -51,7 +51,7 @@ public void $spock_feature_0_0() { } } } - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/multi_parameterization.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/multi_parameterization.groovy index 46a60c3b0c..f62c4ecc61 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/multi_parameterization.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/multi_parameterization.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b) { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } @org.spockframework.runtime.model.DataProviderMetadata(line = 3, dataVariables = ['a', 'b']) diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/nested_multi_parameterization.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/nested_multi_parameterization.groovy index c75a0d9a81..b69a16a4a6 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/nested_multi_parameterization.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/nested_multi_parameterization.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b) { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a == b', 1, 83, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } @org.spockframework.runtime.model.DataProviderMetadata(line = 3, dataVariables = ['a', 'b']) diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[0].groovy index bc7a6f6c49..3b76e38fbd 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[0].groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b, java.lang catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 2, 7, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[1].groovy index bc7a6f6c49..3b76e38fbd 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[1].groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b, java.lang catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 2, 7, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[2].groovy index bc7a6f6c49..3b76e38fbd 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/data_tables_with__separators_can_be_combined-[2].groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b, java.lang catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 2, 7, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/filter_block_becomes_its_own_method.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/filter_block_becomes_its_own_method.groovy index 41477acec2..1d5c855a11 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/filter_block_becomes_its_own_method.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/filter_block_becomes_its_own_method.groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b) { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 2, 7, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/using_a_variable_in_a_cell_multiple_times_compiles.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/using_a_variable_in_a_cell_multiple_times_compiles.groovy index 7cad900b63..14e47872f6 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/using_a_variable_in_a_cell_multiple_times_compiles.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataTablesAstSpec/using_a_variable_in_a_cell_multiple_times_compiles.groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object a, java.lang.Object b, java.lang catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'a + b == result', 2, 9, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsAsSet_is_transformed_correctly.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsAsSet_is_transformed_correctly.groovy index 559426607e..679caa0cb7 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsAsSet_is_transformed_correctly.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsAsSet_is_transformed_correctly.groovy @@ -18,7 +18,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ [1]', 4, 9, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsInAnyOrder_is_transformed_correctly.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsInAnyOrder_is_transformed_correctly.groovy index 1c5f107dd4..8edc2f1e8b 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsInAnyOrder_is_transformed_correctly.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/collection_condition_matchCollectionsInAnyOrder_is_transformed_correctly.groovy @@ -18,7 +18,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ [1]', 4, 9, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_find_conditions_are_transformed_correctly.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_find_conditions_are_transformed_correctly.groovy index 938b35874d..7ccd555b44 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_find_conditions_are_transformed_correctly.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_find_conditions_are_transformed_correctly.groovy @@ -18,7 +18,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x =~ /\\d/', 4, 9, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_match_conditions_are_transformed_correctly.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_match_conditions_are_transformed_correctly.groovy index 62029a6609..a233c3e42a 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_match_conditions_are_transformed_correctly.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/CollectionConditionAstSpec/regex_match_conditions_are_transformed_correctly.groovy @@ -18,7 +18,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'x ==~ /a\\db/', 4, 9, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_explicit_condition.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_explicit_condition.groovy index e40f91ed27..b0c8632184 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_explicit_condition.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_explicit_condition.groovy @@ -11,5 +11,5 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'null.with {\n false\n}', 2, 8, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_implicit_condition.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_implicit_condition.groovy index ec43525cda..a99ed7e5d1 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_implicit_condition.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/GDK_method_that_looks_like_built_in_method_as_implicit_condition.groovy @@ -11,5 +11,5 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'null.with {\n false\n}', 2, 1, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[0].groovy index 2b81a7a7b9..de7b7d31aa 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[0].groovy @@ -11,5 +11,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder1, 'false', 3, 3, null, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[1].groovy index 7c9c224fc4..3745670905 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[1].groovy @@ -15,5 +15,5 @@ public void $spock_feature_0_0() { $spock_errorCollector1.validateCollectedErrors()} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[2].groovy index df19af74d8..4f396a5356 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod-[2].groovy @@ -11,5 +11,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder1, 'false', 3, 3, null, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[0].groovy index 64db7e1791..6cc7654758 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[0].groovy @@ -12,5 +12,5 @@ public void $spock_feature_0_0() { throw new java.lang.Exception('foo') }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[1].groovy index d148ce100a..f22791b475 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[1].groovy @@ -16,5 +16,5 @@ public void $spock_feature_0_0() { $spock_errorCollector1.validateCollectedErrors()} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[2].groovy index 2105cec63b..39a74475e6 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_exception-[2].groovy @@ -12,5 +12,5 @@ public void $spock_feature_0_0() { throw new java.lang.Exception('foo') }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[0].groovy index 384cfb03c8..de8b16d891 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[0].groovy @@ -5,5 +5,5 @@ public void $spock_feature_0_0() { throw new java.lang.Exception('foo') }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[1].groovy index 9cede9702f..88a43a0173 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[1].groovy @@ -5,5 +5,5 @@ public void $spock_feature_0_0() { throw new java.lang.Exception('foo') }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[2].groovy index 2ac010d024..a73fe0e803 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_with_only_exception-[2].groovy @@ -5,5 +5,5 @@ public void $spock_feature_0_0() { throw new java.lang.Exception('foo') }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[0].groovy index 997f454328..c7a96382ed 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[0].groovy @@ -18,5 +18,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[1].groovy index ee1b560ad3..5592263fee 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[1].groovy @@ -27,5 +27,5 @@ public void $spock_feature_0_0() { $spock_errorCollector1.validateCollectedErrors()} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[2].groovy index d9e640727b..66a2d3b25d 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod-[2].groovy @@ -18,5 +18,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[0].groovy index 53b9a4c361..675fd67ba2 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[0].groovy @@ -19,5 +19,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[1].groovy index 352e6754cc..98c4e51e07 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[1].groovy @@ -28,5 +28,5 @@ public void $spock_feature_0_0() { $spock_errorCollector1.validateCollectedErrors()} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[2].groovy index 224489b7ab..9c6eb722a9 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_exception-[2].groovy @@ -19,5 +19,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[0].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[0].groovy index 034ae05f7f..2a55e006b9 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[0].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[0].groovy @@ -13,5 +13,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[1].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[1].groovy index ac4e2fbb20..ffd994da5f 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[1].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[1].groovy @@ -17,5 +17,5 @@ public void $spock_feature_0_0() { $spock_errorCollector1.validateCollectedErrors()} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[2].groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[2].groovy index 5c9ab1bf68..9d7f2cf014 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[2].groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ConditionMethodsAstSpec/condition_method__conditionMethod_within_condition_method__conditionMethod_with_only_exception-[2].groovy @@ -13,5 +13,5 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.groupConditionFailedWithException($spock_errorCollector, $spock_condition_throwable)} }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } \ No newline at end of file diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference.groovy index 6cd5d1d06a..2fd8b5e57b 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference.groovy @@ -23,7 +23,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 1) org.spockframework.runtime.SpecInternals.thrownImpl(this, null, null, java.lang.IllegalStateException) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy index 6bf8c68aec..f901144aaf 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments-groovy5.groovy @@ -23,7 +23,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 1) org.spockframework.runtime.SpecInternals.thrownImpl(this, null, null, java.lang.IllegalStateException) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy index 6bf8c68aec..f901144aaf 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/ExceptionConditionsAstSpec/thrown_rewrite_keeps_correct_method_reference_for_multi_assignments.groovy @@ -23,7 +23,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 1) org.spockframework.runtime.SpecInternals.thrownImpl(this, null, null, java.lang.IllegalStateException) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 1) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy index b0e8ca43da..7d7f469551 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy @@ -19,7 +19,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 3, 5, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/transforms_conditions_in_private_methods.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/transforms_conditions_in_private_methods.groovy index c09609c5cc..a43dbb2ae5 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/transforms_conditions_in_private_methods.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyAllMethodsAstSpec/transforms_conditions_in_private_methods.groovy @@ -94,7 +94,7 @@ public void $spock_feature_0_0() { } }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy index 7e646abfb9..3e016f1288 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/methods_without_condition_declarations_stay_unchanged_in_specs.groovy @@ -19,7 +19,7 @@ public void $spock_feature_0_0() { catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 3, 5, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/transforms_conditions_in_private_methods.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/transforms_conditions_in_private_methods.groovy index 8230fa4b63..b8992d1a5e 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/transforms_conditions_in_private_methods.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/condition/VerifyMethodsAstSpec/transforms_conditions_in_private_methods.groovy @@ -90,7 +90,7 @@ public void $spock_feature_0_0() { } }) org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/mock/MocksAstSpec/simple_interaction.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/mock/MocksAstSpec/simple_interaction.groovy index 2b63ee3b75..5ce312e6b2 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/mock/MocksAstSpec/simple_interaction.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/mock/MocksAstSpec/simple_interaction.groovy @@ -17,7 +17,7 @@ public void $spock_feature_0_0() { org.spockframework.runtime.SpockRuntime.callBlockEntered(this, 2) this.getSpecificationContext().getMockController().leaveScope() org.spockframework.runtime.SpockRuntime.callBlockExited(this, 2) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } /*--------- end::snapshot[] ---------*/ } diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_provider_with_asserting_closure_produces_error_rethrower_variable_in_data_provider_method.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_provider_with_asserting_closure_produces_error_rethrower_variable_in_data_provider_method.groovy index 942ed82ff8..ea1aba3e1f 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_provider_with_asserting_closure_produces_error_rethrower_variable_in_data_provider_method.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_provider_with_asserting_closure_produces_error_rethrower_variable_in_data_provider_method.groovy @@ -4,7 +4,7 @@ import spock.lang.* class ASpec extends Specification { /*--------- tag::snapshot[] ---------*/ public void $spock_feature_0_0(java.lang.Object dataPipe, java.lang.Object dataVariable) { - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_variable_with_asserting_closure_produces_error_rethrower_variable_in_data_processor_method.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_variable_with_asserting_closure_produces_error_rethrower_variable_in_data_processor_method.groovy index 37292164ec..bb7cfc3aab 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_variable_with_asserting_closure_produces_error_rethrower_variable_in_data_processor_method.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/parameterization/DataProviders/data_variable_with_asserting_closure_produces_error_rethrower_variable_in_data_processor_method.groovy @@ -4,7 +4,7 @@ import spock.lang.* class ASpec extends Specification { /*--------- tag::snapshot[] ---------*/ public void $spock_feature_0_0(java.lang.Object dataPipe, java.lang.Object dataVariable) { - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0() { From d61dc0090dc239188c165fccab2d93035c8fead8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 11 Jun 2026 15:24:38 +0200 Subject: [PATCH 2/3] Review Feedback Vol. 1 --- docs/interaction_based_testing.adoc | 2 +- docs/release_notes.adoc | 2 +- .../smoke/mock/GlobalInteractionsInCleanup.groovy | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/interaction_based_testing.adoc b/docs/interaction_based_testing.adoc index cbb3cfbf6b..5c2f82e382 100644 --- a/docs/interaction_based_testing.adoc +++ b/docs/interaction_based_testing.adoc @@ -444,7 +444,7 @@ This makes sure that `subscriber` receives `"message1"` during execution of the and `"message2"` during execution of the second `when:` block. Interactions declared outside a `then:` block are active from their declaration until the end of the -containing feature method plus an eventually existing `cleanup` method. +containing feature method, plus any `cleanup` methods. Interactions are always scoped to a particular feature method. Hence they cannot be declared in a static method, `setupSpec` method, or `cleanupSpec` method. Likewise, mock objects should not be stored in static or `@Shared` diff --git a/docs/release_notes.adoc b/docs/release_notes.adoc index f9c76b6c53..64452fa070 100644 --- a/docs/release_notes.adoc +++ b/docs/release_notes.adoc @@ -25,7 +25,7 @@ include::include.adoc[] === Breaking Changes * Mock/Stub checks on `Comparable` with `T` being something other than `Object` now compare using the java identity hash code instead of always being equal spockIssue:2352[] -* Interactions outside a `then:` block are now still active in an eventually existing `cleanup` method. +* Interactions outside a `then:` block are now still active in any eventually existing `cleanup` methods. If the interaction contains a lower cardinality, this is still checked at the end of the feature method. Upper cardinality is still relevant in the `cleanup` method, so could cause test failures where previously simply the default response of the mock object was used without cardinality check and could now cause previously working tests to fail. This enables `cleanup` methods to get stubbed responses from mock objects which previously was only possible by using a custom default response. diff --git a/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy b/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy index faefbfe30a..7def614f94 100644 --- a/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy +++ b/spock-specs/src/test/groovy/org/spockframework/smoke/mock/GlobalInteractionsInCleanup.groovy @@ -23,8 +23,18 @@ import spock.lang.Specification import java.util.function.Function +abstract class GlobalInteractionsInCleanupSuperSpec extends Specification { + def cleanup() { + verifyAll { + mock.apply("a") == "b" + mock2.apply("a") == "c" + mock3.apply("a") == "d" + } + } +} + @Issue("https://github.com/spockframework/spock/issues/616") -class GlobalInteractionsInCleanup extends Specification { +class GlobalInteractionsInCleanup extends GlobalInteractionsInCleanupSuperSpec { def mock = Mock(Function) def mock2 = Mock(Function) { apply("a") >> { "c" } From 0e52358da80bc3f811618e6b7a956f3f9f79ebaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 8 Jul 2026 12:27:47 +0200 Subject: [PATCH 3/3] Rebase from master --- .../smoke/ast/DataAstSpec/where_block_variables.groovy | 2 +- ...e__derived_variables__cross_multiplication_and_filter.groovy | 2 +- ...re_block_variables_with_multiple_assignment-groovy3_4.groovy | 2 +- ...here_block_variables_with_multiple_assignment-groovy5.groovy | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables.groovy index 2fa8972852..d4f541029f 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0(java.lang.Object name, java.lang.Object greeting) catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'greeting == \"Hello, world\"', 1, 83, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } @org.spockframework.runtime.model.DataProviderMetadata(line = 4, dataVariables = ['name']) diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_combined_with_data_table__data_pipe__derived_variables__cross_multiplication_and_filter.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_combined_with_data_table__data_pipe__derived_variables__cross_multiplication_and_filter.groovy index 278afeea62..c411e99aa6 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_combined_with_data_table__data_pipe__derived_variables__cross_multiplication_and_filter.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_combined_with_data_table__data_pipe__derived_variables__cross_multiplication_and_filter.groovy @@ -14,7 +14,7 @@ public void $spock_feature_0_0(java.lang.Object x, java.lang.Object y, java.lang catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'true', 2, 5, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } public java.lang.Object $spock_feature_0_0prov0(java.lang.Object base, java.lang.Object sep) { diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy3_4.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy3_4.groovy index 94aa72a87c..fff4544812 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy3_4.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy3_4.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0(java.lang.Object name, java.lang.Object greeting) catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'greeting == \"Hello, world!\"', 1, 83, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } @org.spockframework.runtime.model.DataProviderMetadata(line = 4, dataVariables = ['name']) diff --git a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy5.groovy b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy5.groovy index 94aa72a87c..fff4544812 100644 --- a/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy5.groovy +++ b/spock-specs/src/test/resources/snapshots/org/spockframework/smoke/ast/DataAstSpec/where_block_variables_with_multiple_assignment-groovy5.groovy @@ -15,7 +15,7 @@ public void $spock_feature_0_0(java.lang.Object name, java.lang.Object greeting) catch (java.lang.Throwable $spock_condition_throwable) { org.spockframework.runtime.SpockRuntime.conditionFailedWithException($spock_errorCollector, $spock_valueRecorder, 'greeting == \"Hello, world!\"', 1, 83, null, $spock_condition_throwable)} org.spockframework.runtime.SpockRuntime.callBlockExited(this, 0) - this.getSpecificationContext().getMockController().leaveScope() + this.getSpecificationContext().getMockController().verifyLastScope() } @org.spockframework.runtime.model.DataProviderMetadata(line = 4, dataVariables = ['name'])