Skip to content

Pytest-BDD parse matcher step definitions #205

Closed
@neskk

Description

@neskk

👓 What did you see?

I've configured the cucumber plugin to look for step defs in the right paths, but it's not matching the step-defs.

    "cucumber.features": [
        "**/tests/**/*.feature",
    ],
    "cucumber.glue": [
        "**/step_defs/**/*.py"
    ],

It finds and parses the files but does not recognize the step-defs:

[Info  - 10:45:53 PM] * Found 7 feature file(s) in ["src/test/**/*.feature","features/**/*.feature","tests/**/*.feature","*specs*/**/*.feature","**/tests/**/*.feature"]
[Info  - 10:45:53 PM] * Found 74 steps in those feature files
[Info  - 10:45:54 PM] * Found 26 glue file(s) in ["**/step_defs/**/*.py"]
[Info  - 10:45:54 PM] * Found 0 parameter types in those glue files
[Info  - 10:45:54 PM] * Found 0 step definitions in those glue files
[Info  - 10:45:54 PM] * Built 52 suggestions for auto complete

Example step-def:

from pytest_bdd import given, parsers, then, when

@given(parsers.parse("a stub exists with:" + os.linesep + "{stub_str}"))
@when(parsers.parse("creating a stub with:" + os.linesep + "{stub_str}"))
def creating_stub_with(
    request: pytest.FixtureRequest,
    context: handler.DynamicValuesHandler,
    mock_server: MockServerClient,
    stub_str: str,
) -> Stub:
    ...

We implemented most of the step-defs like this, using pytest_bdd parsers.
Is this "parsers" format compatible with the cucumber plugin?


Another question I have is in regards to external libraries with step definitions.
Currently at my company we're using a shared library that implements the most common step-defs we use in our tests.

Will the vscode cucumber plugin also pick these definitions as well from imports?

Thank you!

I can try to setup a full example if needed.

✅ What did you expect to see?

I expected step definitions to be recognized and be able to use the plugin tools.

📦 Which tool/library version are you using?

cucumber plugin v1.10
vscode 1.88.1

🔬 How could we reproduce it?

No response

📚 Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions