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

Introduce mandatory Scenario State #255

Closed
janschaefer opened this issue Nov 23, 2016 · 5 comments · Fixed by #264
Closed

Introduce mandatory Scenario State #255

janschaefer opened this issue Nov 23, 2016 · 5 comments · Fixed by #264

Comments

@janschaefer
Copy link
Contributor

It would be useful to have an attribute mandatory = true in the @ScenarioState annotation. If this is set, JGiven will fail if no such @ScenarioState would have been provided.

Example:

class MyStage {
    @ScenarioState(mandatory = true)
    String mandatoryState;
}
@Airblader
Copy link
Contributor

There's also @ExpectedScenarioState and @ProvidedScenarioState, though I'd argue that this feature makes no sense in the latter of these two.

Airblader added a commit to Airblader/JGiven that referenced this issue Dec 21, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
Airblader added a commit to Airblader/JGiven that referenced this issue Dec 23, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
Airblader added a commit to Airblader/JGiven that referenced this issue Dec 24, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
Airblader added a commit to Airblader/JGiven that referenced this issue Dec 24, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
Airblader added a commit to Airblader/JGiven that referenced this issue Dec 24, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
Airblader added a commit to Airblader/JGiven that referenced this issue Dec 24, 2016
This commit adds a new boolean attribute "required" to both
ScenarioState and ExpectedScenarioState. If set to true on a
field within a stage, corresponding tests will fail automatically
if the state hasn't been provided.

fixes TNG#255
@janschaefer janschaefer reopened this Dec 26, 2016
@janschaefer janschaefer reopened this Dec 26, 2016
@janschaefer
Copy link
Contributor Author

janschaefer commented Dec 26, 2016

There is a problem with the new feature. When you have a test method that is annotated with @Pending an exception is thrown when the field is not set. Expected behavior: the error should not be thrown.

@Airblader
Copy link
Contributor

I think this would be rather dificult to fix in a clean way. Feel free to revert for now.

@janschaefer janschaefer added this to the v0.14.0 milestone Dec 29, 2016
@janschaefer
Copy link
Contributor Author

It was actually quite easy to fix :-)

@Airblader
Copy link
Contributor

I wasn't aware that something like suppressExceptions already existed for pending tests. All the better. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants