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

Ability to reusable steps, specifically inside a plugin #754

Open
kingbuzzman opened this issue Dec 12, 2024 · 1 comment
Open

Ability to reusable steps, specifically inside a plugin #754

kingbuzzman opened this issue Dec 12, 2024 · 1 comment

Comments

@kingbuzzman
Copy link

Is your feature request related to a problem? Please describe.
Kind of. There is no obvious way to reuse steps from an import. Specifically, I need a straightforward approach to specify at which level these reused steps should be applied. Without this, the process of integrating shared steps across different tests becomes unclear and cumbersome.

Describe the solution you'd like
My current solution, is very nasty, needs a sanity check. Ideally, I'd like a clean, well-structured method that allows me to define and reuse these steps at various levels within my tests, ensuring a more maintainable and understandable codebase.

Describe alternatives you've considered
I’ve experimented with multiple approaches in the codebase, but each attempt has only deepened my confusion. Nothing so far has provided a clear, reliable pattern for managing and reusing these steps effectively.

Additional context
NA


The overarching goal of my project is to establish predefined, shareable test steps that handle mundane operations—such as setting up data, calling a URL, and then verifying data—in a highly explicit and readable manner. This would simplify common testing patterns and promote consistency across projects. For example:

  1. setup data
  2. call url
  3. check data

Rinse and repeat.

@youtux
Copy link
Contributor

youtux commented Dec 12, 2024

what about defining your steps in tests/steps.py, and do from tests.steps import * in the modules you need them?
You can even exploit the pytest fixture definition hierarchy, since functions decorated with @given / @when / @then are actually fixtures under the hood.

For example, you can do from tests.steps.global_steps import * in your main tests/conftest.py, and in child packages of your test suite you can then do more granular imports. E.g. in tests/foo/conftest.py you can do from tests.steps.foo_specific_steps import *

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

No branches or pull requests

3 participants