-
Notifications
You must be signed in to change notification settings - Fork 638
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
Require ability to skip a specific step only but continue with rest of the steps of the scenario #1057
Comments
Could you explain why you need such a functionality? NOTES:
|
I am automating a highly dynamic application. Hence, I decided to test each fields in separate scenario so that I can skip tests using tags(scenario level) for those fields which need not be covered for current screen.
However, there are some tests(scenarios) which test for all fields in the page. The test would not be meaningful if I segregated them field wise. Hence I thought, if I could skip steps inside a scenario then it would have been very flexible to impl. such case.
Otherwise, my coverage would be less. Let me know if this helps. Note: I am not looking to reverse target scenarios/features using tags applied in steps. All I need is data in I understand your point and have raised a isuse in gherkin repo too. Also, tags at step level is also supported in SpecFlow (https://docs.specflow.org/projects/specflow/en/latest/Bindings/Scoped-Step-Definitions.html) |
@jenisys just a humble reminder. As requested, the details are added. Kindly let us know the way forward. |
Mmh, I do not think that you need tags for steps in Gherkin.
BETTER EXAMPLE: That tests the business rule (that was mentioned above). # -- FILE: features/better_example.feature
...
Scenario Outline: Valid ZIP code automatically resolves city and state info
Given a valid ZIP code "<zip-code> was provided
Then the field "city" should have the value "<city>"
And the field "state" should have the value "<state>"
Examples: # TODO: Valid zip-code must be provided in the following table.
| zip-code | city | state |
| xxxxx_1 | Chicago | IL |
| xxxxx_2 | San Francisco | CA | OTHER SOLUTION 1: Generate features for what you need Use a template engine (like Jinja2) to generate feature files with scenarios what you really need. OTHER SOLUTION 2: Use active-tags (skip-if on scenario) if ZIP code is entered outside of the scenario Note that can be a "smell" that you are probably using scenarios in a wrong way. The # -- FILE: features/example_with_active-tag.feature
@use.with_page_contains_field="zip-code"
Scenario: Provided ZIP code automatically resolves city and state info
# HINT: User entered ZIP code outside of this scenario.
Then the field "city" should have the value "<zip-code.city>"
And the field "state" should have the value "<zip-code.state>"
... SEE: active-tags OTHER SOLUTION 3: Use better step semantics Be more concise with your steps and provide steps that gracefully ignore something (a field is not present). # -- FILE: features/example.feature
...
Scenario: Provided ZIP code automatically resolves city and state info
Given the ZIP code "12345" is provided
...
Then the existing field "city" should have the value "<city>" # -- FILE: features/steps/field_steps.py
@then(u'a field "{field_name}" should have the "{expected_value}"')
def step_then_field_should_have_value(ctx, field_name, expected_value):
actual_value = ctx.data_access_provider.get_field(field_name)
assert actual_value == expected_value
@then(u'an existing field "{field_name}" should have the "{expected_value}"')
def step_then_existing_field_should_have_value(ctx, field_name, expected_value):
if not ctx.data_access_provider.has_field(field_name):
# -- CASE: MISSING FIELD, skip further step processing.
# BUT: Step.status is PASSED; step is gracefully ignored because precondition is not met.
return
# -- REUSE: Other existing step implementation
step_then_field_should_have_value(ctx, field_name, expected_value) NOTES: On SpecFlow tags for step implementations as scoping mechanism |
Thanks @jenisys for elaborate explanation.
I understand you made a right point here. This automation framework was intended to be used for functional testing. But later was extended to include frontend tests (verification tests) The solutions 2 & 3 would not help in this case. Since, I need to continue with the rest of the steps. Also, I only wish to skip them when UI QA has specified that they don't expect a particular field to be present in the page. (provided in the config.ini) I will try solution 1 but it would have been lot easier if I could get tags info at step level. Thanks again! |
Is it possible to provide a functionality to:
for eg:
for eg:
The text was updated successfully, but these errors were encountered: