Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    jenisys
    @jenisys

    @heksesang The data source of the i18n translations is a YAML file. It is used to generate the behave.i18n module. Therefore, no. But you can do it if you have checked out the source repository and install your updated/patched version of behave afterwards. The normal process is to provide a pull-request to the cucumber repo that host this data file and then PR/issue to update it in behave.

    What are you exactly missing and in which language?

    1 reply
    jenisys
    @jenisys
    @c-cri35 Your python search path may be wrong (PYTHONPATH environment variable). Python probably does not know where to find your module. In the directory where you want ton run behave, open a Python shell and try: from custom_runner.runner_wrapper import CustomRunner or import custom_runner.runner_wrapper. If you get an ImportError(or derived exception), setup your PYTHONPATH environment variable correctly.
    1 reply
    jenisys
    @jenisys
    @heksesang The data schema supports multiple words for each keyword. Therefore, you could provide as additional alias. But it is up to you to obey your conventions (that it is only used fro then steps).
    Note that @aslakhellesoy from the Cucumber core team is Norwegian, too (AFAIK).
    Otherwise, And is a good combine word for additional steps of the same type (at least in my opinion).
    heksesang
    @heksenlied:matrix.org
    [m]
    But I would still need to recompile or provide a PR with these updates to create multiple aliases like that?
    jenisys
    @jenisys
    Ye
    Yes
    jenisys
    @jenisys
    @c-cri35 Try it with behave —runner-class custom_runner.runner_wrapper:CustomRunner (using a colon instead of a dot at the module boundary to the class).
    1 reply
    jenisys
    @jenisys
    @c-cri35 No, a virtualenv is no problem. If you can import it in your Python shell, the Python executable that is used to running behave performs the same.
    7kilobytes
    @7kilobytes
    hello everyone. Is it possible to have common steps in feature file, but different implementations in the steps?
    7kilobytes
    @7kilobytes
    for example I have the following feature file: https://bpa.st/4X5A but test results should be different for each scenario
    jenisys
    @jenisys
    @7kilobytes The then step would need a „test oracle“ to know somehow what the correct results mean. Otherwise/Normally, you have a given step that specifies the correct result parts or indirectly stores these in the context variable (or store a validator object). This context variable can then be used by the then step to know what the correct results really mean. Therefore, you have only one step implementation, but you can build in some indirection to make it more flexible or „intelligent“ (and depends on the earlier executed steps logic).
    @7kilobytes An additional hint: The context is a layered object. The Scenario layer is removed/popped at the end of the scenario (and all variables that were added to it in before_scenario() / after_scenario(), before_step() / after_step() hooks and in steps). Therefore, the second/next scenario receives a clean context object.
    7kilobytes
    @7kilobytes
    @jenisys thank you very much. Yes, I need to change results )
    7kilobytes
    @7kilobytes
    could somebody explain how can I pass the same URL in the steps?
    I receive the following error:
    behave.step_registry.AmbiguousStep: @given('I am on "{url}" page') has already been defined in
    jenisys
    @jenisys
    @7kilobytes You seem to have two step implementation functions that have or match the same step text. In general, get rid of the second implementation. If you have different step-matcher patterns, defining them in the „correct“ order helps (put the step with the more specific/longer pattern in front). Otherwise, use specific placeholder types, like {name:w} that matches only one word instead of the match anything pattern. You already double-quoted the placeholder param. That helps in general (hint: regular expression pattern marchers, which are under the hood, are often greedy. That means they match as much as possible).
    7kilobytes
    @7kilobytes
    @jenisys thanks. How can I "reuse" the same implementation for two different scenarios? Using Background?
    One more question: is it better to split one feature file to the several smallest ones?
    excuse me for the stupid questions. I have never used behave before
    jenisys
    @jenisys
    @7kilobytes Step implementations are independent of scenarios and features. The step implementation must be either in the „modules“ under the „features/steps/“ directory or imported via one of these step modules.
    jenisys
    @jenisys
    @7kilobytes Related to Feature file split-up or not:
    In general, that depends on you and how complex the feature file is (how many scenarios). In general, you should have one feature file for one feature. This allows you to test a specific feature by running the feature file with behave. If it gets too complex, split it up but use some common filename prefix to indicate that all feature files belong together. This common prefix naming approach helps you also to test the complete feature by using: behave features/feature_one.*.feature (run all feature files to test feature_one).
    7kilobytes
    @7kilobytes
    great. Thank you again
    c-cri35
    @c-cri35
    Hello! I was playing with the asterisk ( * ) keyword and it seems like the parser always treats this case as a Given step. The cucumber documentation hints that (*) can be used instead of any keyword. Shouldn't steps defined with (*) keyword be treated as an and/but when parsing? That is they should at least have the same type of the last registered step.
    m_waheed
    @m_waheed:matrix.org
    [m]

    Hi everyone, is there a way to reuse a step definition when that step is used in the feature files as both Given and Then?

    Exact same step, just used as a Given in one feature, and as a Then in another feature, so they resolve to different step definitions, can I make them resolve to the same definition, so that I reuse my step?

    Thanks a lot in advance :)

    jenisys
    @jenisys
    @c-cri35 Use both @given and @them decorator on step implementation function. In general that works better with given/when step pairs because the then-step normally asserts something.
    m_waheed
    @m_waheed:matrix.org
    [m]
    @jenisys: I didn't know that was possible, because I haven't studied decorators enough. but this actually worked for my case too, Thank you :)
    Krzysztof Wozniak
    @Hejvi
    Hello, I am wondering whether is possible to change/expand in a fly the tag name? For example: I run tests from the command line using --tags @xyz but I want to run under the hood the @a.name.1 @b.name.2 and @c.group.1.
    Krzysztof Wozniak
    @Hejvi

    Hi everyone, is there a way to reuse a step definition when that step is used in the feature files as both Given and Then?

    Exact same step, just used as a Given in one feature, and as a Then in another feature, so they resolve to different step definitions, can I make them resolve to the same definition, so that I reuse my step?

    Thanks a lot in advance :)

    If I understand correctly, you can also use @step in your decorator instead of @given / @then

    jenisys
    @jenisys
    @Hejvi Regarding replacing the tags or tag-expression: No that is not (easily) possible.
    Could you explain why you actually need such a feature/functionality?
    @Hejvi With the newer tag-expression syntax (current tip of the repository), you could state: —tags=„@*.name.* or @c.group.1“ (or: and, if that is intended)
    Krzysztof Wozniak
    @Hejvi
    @jenisys I already use tag-expression syntax for tag name/group. Let's say I would like to run over a dozen tags from different feature files including only specific cases from the scenario outlines. That's why I am looking for a way to run over a dozen tags like (x.name.1, y.name.2, z.group.1) using only a single tag.
    Krzysztof Wozniak
    @Hejvi
    Oh, I noticed that I can tag only Examples instead of whole Scenario which probably solves my problem :)
    jenisys
    @jenisys
    @Hejvi I assume it is not possible to add that one tag that your looking for to the Features/Scenarios/Example to select that „set of interest“ ?! Tags are normally just used like that. If you really need such a large number of tags is best solved by a level of indirection, a „build system“ that does just what you want. Otherwise, you could just use „at-files“, a textual file with file locations, like: behave @testsuite_1.txt. But file locations are in general more brittle than tags. A file location has the scheme: <FILENAME>:<LINE_NUMBER> to select its scenario(s) or ScenarioOutline example row.
    Krzysztof Wozniak
    @Hejvi
    @jenisys Thank you. Do you have somewhere an example of the implementation of textual files?
    Krzysztof Wozniak
    @Hejvi
    thanks!
    Krzysztof Wozniak
    @Hejvi
    Hello, I am trying to find a way to parameterize the fixture-tag. I have found behave/behave#899 but looks like the source for "here" is missing? @jenisys
    jenisys
    @jenisys
    @Hejvi That was a clarification statement and not „here is an example“. Parametrized tags as suggested by #899 will require that parsing of tags will be more complex. Currently, tags are basically words separated by whitespace.
    Krzysztof Wozniak
    @Hejvi
    My mistake, thanks
    Krzysztof Wozniak
    @Hejvi

    Hello, is there a way to put table keys as the first column instead of the header? Like:

    | KMSY | Louis Armstrong New Orleans International Airport |
    | KSFO | San Francisco International Airport |
    | KSEA | Seattle–Tacoma International Airport |
    | KJFK | John F. Kennedy International Airport |

    jenisys
    @jenisys
    @Hejvi I assume you want to use it as DataTable for a step !?!
    Currently, this is not directly supported.
    The Gherkin parser stores it in a behave.model.Table which currently expects column headers. Your step would need to transform/transpose the table into your format (a property-table view). This can be done by a helper/utility function in your step or by a step-decorator that performs the same work.
    VamshiKrishnaUM
    @VamshiKrishnaUM
    Hello,
    Hello, is there a way to find which tag invoked current scenario in "after_scenario" hook ?
    jenisys
    @jenisys
    @VamshiKrishnaUM You mean which tags a scenario has ?
    VamshiKrishnaUM
    @VamshiKrishnaUM
    No, like which tag has triggered the current scenario.
    Eg: behave something.feature --tags @first
    Incase my_scenario is tagged with @first @second @third
    jenisys
    @jenisys
    Tags trigger no scenario. They are only used to select or filter out a scenario. To access the tags , use context.scenario.tags
    Michael Mintz
    @mdmintz
    I created a few integrations for behave. One: a more natural Selenium integration. Two: A Desktop GUI for running behave tests. And Three: A Dashboard for reporting behave results with a pie chart and table data. https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md