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

how to achieve multiple scenario-outlines in single feature file in pytest-bb ? #462

Open
ajaygoutham1995 opened this issue Nov 23, 2021 · 6 comments
Labels
awaiting response Awaiting response from the reporter

Comments

@ajaygoutham1995
Copy link

I have given the code like this but it's not working, your response would be more helpful.

Feature: login feature
Scenario Outline: login with valid credentials
Given login with valid and
Examples:
|username |password |
|[email protected]|newyear2022|

Scenario Outline: login with InCorrect credentials
  Given login with incorrect <username> and <password>
  Examples:
    |username  |password |
    |[email protected]|sjbcjsbakjsans|

implementation

@Scenario(
"../features/login.feature",
"login with valid credentials",

)
def test_after():
pass

@given(parsers.parse("login with valid {username} and {password}"))
def test_valid_login(username,password):
print()
print(username,password)

@given(parsers.parse("login with incorrect {user} and {psw}"))
def test_invalid_login(user,psw):
print()
print(user,psw)

@elchupanebrej
Copy link

Hi! Please provide more clear info about your environment and pytest output. Also please check the markup of your message, seems github eat some info

@ghost
Copy link

ghost commented Jan 17, 2022

@elchupanebrej
I also faced similar issue.
Issue Description :
If we are trying to add two different scenario outline in single feature file as below :

#login.feature 

Feature: login feature
   Scenario Outline: login with valid credentials
      Given login with valid <username> , <password>and <otp> 
      Examples:
      |username                |password      | otp      |
      |[email protected]|newyear2022|123123|

   Scenario Outline: login with InCorrect credentials
      Given login with incorrect <username> , <password> 
      Examples:
      |username                       |password       | 
      |[email protected]|sjbcjsbakjsans|  

As per my understanding this is not working. As a work around, for now one Scenario Outline in one file is working. Please review and let me know if there is a way to achieve the same.

Exception :

../../../.local/lib/python3.8/site-packages/pytest_bdd/scenario.py:327: in scenarios
    @scenario(feature.filename, scenario_name, **kwargs)
../../../.local/lib/python3.8/site-packages/pytest_bdd/scenario.py:244: in scenario
    scenario.validate()
../../../.local/lib/python3.8/site-packages/pytest_bdd/parser.py:269: in validate
    raise exceptions.ScenarioExamplesNotValidError(

 pytest_bdd.exceptions.ScenarioExamplesNotValidError: Scenario " Scenario description "    in the feature
 "Feature File Details " has not valid examples. Set of step parameters  

I believe it is clubbing all the examples together somehow.

Any help will be appreciated . Please let me know in case I'm doing anything wrong here .

@ghost
Copy link

ghost commented Jan 17, 2022

I think I found the root cause. It is happening only when there is space here Scenario Outline : if I'm writing is without space i.e.
Scenario Outline: its working as expected. It could look like minor issue , but it took lot of my time. Please be careful while using this. As a summary Scenario Outline<avoid_space_here>:

@Hari-G-S
Copy link

Hari-G-S commented May 6, 2022

I am trying without space. I have two scenario outlines. Still its executing only one scenario outline( And it is picking only second scenario)

@elchupanebrej
Copy link

Could you please try https://pypi.org/project/pytest-bdd-ng/ as a replacement for pytest-bdd? There official parser is used

@jsa34
Copy link
Collaborator

jsa34 commented Nov 28, 2024

@ajaygoutham1995 @Hari-G-S

Could check if this still an issue with version 8.0.0?

@jsa34 jsa34 added the awaiting response Awaiting response from the reporter label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Awaiting response from the reporter
Projects
None yet
Development

No branches or pull requests

4 participants