Code Monkey home page Code Monkey logo

Comments (18)

bubenkoff avatar bubenkoff commented on May 28, 2024 1

@evbo do you mean https://github.com/pytest-dev/pytest-bdd#test-code-generation-helpers
but it's a generation of the step definitions, not the steps. The vice versa wouldn't make any sense to me, as this is a behavior-driven development, where the feature in plain text precedes anything else.

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

But there's auto generation for that
Did you try it?
On Mar 16, 2015 7:12 PM, "Leonardo Santagada" [email protected]
wrote:

pytest-bdd would be much more awesome if it would auto create scenario
functions, so you wouldn't have to define empty functions just to make the
test go. I think this either could be implemented as a test collector (also
would make the test reporter more user friendly as it would show the
feature file as the source of tests) or it could be just a invocation form
of scenario function like:

scenario('feature/something.feature', auto=True)


Reply to this email directly or view it on GitHub
#103.

from pytest-bdd.

blueyed avatar blueyed commented on May 28, 2024

@bubenkoff
Are you referring to https://github.com/pytest-dev/pytest-bdd/blob/master/README.rst#test-code-generation-helpers?

I think what @santagada is a bit more involved (if I understand it correctly): the advanced code generator would say "Scenario is not bound to any test":

Please place the code above to the test file(s):

@scenario('tests/generation.feature', 'Code is generated for scenarios which are not bound to any tests')
def test_Code_is_generated_for_scenarios_which_are_not_bound_to_any_tests():
    """Code is generated for scenarios which are not bound to any tests."""

But this seems to be redundant. It would be nice if the scenario files could
be considered to be (pytest) tests automatically.

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

Yes I'm about that
I wanted all of interested people to play with existing possibilities first.
I'm more than open for the change, just it should really improve things.
On Mar 16, 2015 10:46 PM, "Daniel Hahler" [email protected] wrote:

@bubenkoff https://github.com/bubenkoff
Are you referring to
https://github.com/pytest-dev/pytest-bdd/blob/master/README.rst#test-code-generation-helpers
?

I think what @santagada https://github.com/santagada is a bit more
involved (if I understand it correctly): the advanced code generator would
say "Scenario is not bound to any test":

Please place the code above to the test file(s):

@Scenario('tests/generation.feature', 'Code is generated for scenarios which are not bound to any tests')
def test_Code_is_generated_for_scenarios_which_are_not_bound_to_any_tests():
"""Code is generated for scenarios which are not bound to any tests."""

But this seems to be redundant. It would be nice if the scenario files
could
be considered to be (pytest) tests automatically.


Reply to this email directly or view it on GitHub
#103 (comment)
.

from pytest-bdd.

blueyed avatar blueyed commented on May 28, 2024

Cool.

What are your current thoughts on providing this?
I see that behave does this automatically.

I've thought that maybe pytest would require the test functions to collect any tests, but that can be certainly hooked into / provided in a different way.

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

there are discussions in #89 and #92

from pytest-bdd.

blueyed avatar blueyed commented on May 28, 2024

I like the idea from #90 (comment), where you would import / create tests for a set of scenarios:

scenarios('my.feature')

This could then also support using directories (with or without recursion), which would allow to set up all features like:

scenarios()

And for directories:

scenarios('frontend', recurse=True)  # recurse=True could be the default

It's probably useful to also accept an iterable here, allowing to fine tune it using some generators etc.

(please keep in mind that I am new to pytest-bdd, so am lacking any experience in this regard)

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

this will only work for simple cases, but if you'll need to parametrize certain test directly on the function level, then you'll need a way to exclude certain test from that automatic 'suite'

from pytest-bdd.

santagada avatar santagada commented on May 28, 2024

The problem with the generator is that it is too manual. There should be some way to auto collect tests, just like py.test does for functions and all.

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

I'll try to experiment with this (again)

from pytest-bdd.

santagada avatar santagada commented on May 28, 2024

It is starting to look good 👍

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

2.7.0. is out
please play and say what you think

from pytest-bdd.

spinus avatar spinus commented on May 28, 2024

@bubenkoff I only wanted to say cheers, good stuff :-)

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

@spinus thanks, have you tried it?

from pytest-bdd.

spinus avatar spinus commented on May 28, 2024

Yes, works almost nice :-) (#138)

from pytest-bdd.

evbo avatar evbo commented on May 28, 2024

@bubenkoff as a newcomer to pytest-bdd, it's very hard to discern in your docs how to automatically generate feature files from .._test.py files, or vice-a-versa.

Could you link me to where it's documented how to generate 1 from the other?

from pytest-bdd.

evbo avatar evbo commented on May 28, 2024

@bubenkoff thank you, that's perfect and I answered a similar Discussion with references. Someone else was also looking for a way to define .features from test code.

Here's my take on what people like me are looking for: A way to automatically document their code (auto-convert to .feature or .md markup), while writing tests, without a product owner necessarily in the loop (for very small teams or single person businesses).

I don't think what I'm looking for exists and maybe writing my own CLI that parses the Python code of pytests wouldn't be so hard. Thank you otherwise for a great repo, maybe my use case just isn't a good fit for it.

from pytest-bdd.

bubenkoff avatar bubenkoff commented on May 28, 2024

from pytest-bdd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.