Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify the iteration is given to specification context #1686

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void runParameterizedFeature(SpockExecutionContext context, ParameterizedFeature

void runInitializer(SpockExecutionContext context) {
getSpecificationContext(context).setCurrentFeature(context.getCurrentFeature());
getSpecificationContext(context).setCurrentIteration(context.getCurrentIteration());
runInitializer(context, context.getSpec());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setCurrentFeature(FeatureInfo currentFeature) {
@Override
public IterationInfo getCurrentIteration() {
if (currentIteration == null) {
throw new IllegalStateException("Cannot request current iteration in @Shared context");
throw new IllegalStateException("Cannot request current iteration in @Shared context, or feature context");
}
return currentIteration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ class FooSpec extends Specification {
} catch (IllegalStateException ise) {
assert ise.message == 'Cannot request current feature in @Shared context'
}
try {
currentIteration
assert false: 'currentIteration should not be set'
} catch (IllegalStateException ise) {
assert ise.message == 'Cannot request current iteration in @Shared context, or feature context'
}
}
}
}
Expand All @@ -268,6 +274,12 @@ class FooSpec extends Specification {
} catch (IllegalStateException ise) {
assert ise.message == 'Cannot request current feature in @Shared context'
}
try {
currentIteration
assert false: 'currentIteration should not be set'
} catch (IllegalStateException ise) {
assert ise.message == 'Cannot request current iteration in @Shared context, or feature context'
}
}
}
}
Expand All @@ -285,6 +297,12 @@ class FooSpec extends Specification {
instance.specificationContext.with {
assert currentSpec
assert currentFeature
try {
currentIteration
assert false: 'currentIteration should not be set'
} catch (IllegalStateException ise) {
assert ise.message == 'Cannot request current iteration in @Shared context, or feature context'
}
}
}
}
Expand All @@ -302,6 +320,7 @@ class FooSpec extends Specification {
instance.specificationContext.with {
assert currentSpec
assert currentFeature
assert currentIteration
}
}
}
Expand All @@ -319,6 +338,7 @@ class FooSpec extends Specification {
instance.specificationContext.with {
assert currentSpec
assert currentFeature
assert currentIteration
}
}
}
Expand Down