How to use the behave.model.Scenario function in behave

To help you get started, we’ve selected a few behave examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github behave / behave / tests / unit / test_formatter.py View on Github external
def _scenario(self, keyword=u"k\xe9yword", name=u"name", tags=None, steps=None):
        if tags is None:
            tags = []
        if steps is None:
            steps = []
        line = self.line
        tags = [Tag(name, line) for name in tags]
        return Scenario("", line, keyword, name, tags=tags, steps=steps)
github behave / behave / tests / unit / test_model.py View on Github external
def test_skipped_steps_set_step_status_and_scenario_status_if_not_set(self):
        self.config.stdout_capture = False
        self.config.log_capture = False
        self.config.tag_expression.check.return_value = False  # pylint: disable=no-member

        steps = [Mock(), Mock()]
        scenario = Scenario("foo.feature", 17, u"Scenario", u"foo",
                            steps=steps)

        scenario.run(self.runner)

        assert False not in [s.status == Status.skipped for s in steps]
        assert scenario.status == Status.skipped
github behave / behave / tests / unit / test_model.py View on Github external
def test_run_invokes_formatter_scenario_and_steps_correctly(self):
        self.config.stdout_capture = False
        self.config.log_capture = False
        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        steps = [Mock(), Mock()]
        scenario = Scenario("foo.feature", 17, u"Scenario", u"foo",
                            steps=steps)

        scenario.run(self.runner)

        self.formatters[0].scenario.assert_called_with(scenario)
        for step in steps:
            step.run.assert_called_with(self.runner)
github behave / behave / behave / model.py View on Github external
# -- STEP: Make Scenario name for this row.
                # scenario_line = example.line + 2 + row_index
                scenario_line = row.line
                scenario = Scenario(scenario_outline.filename, scenario_line,
                                    scenario_outline.keyword,
                                    scenario_name, row_tags, new_steps)
                scenario.feature = scenario_outline.feature
                scenario.parent = scenario_outline
                scenario.background = scenario_outline.background
                scenario.description = scenario_outline.description
                scenario._row = row     # pylint: disable=protected-access
                scenarios.append(scenario)
        return scenarios


class ScenarioOutline(Scenario):
    """A `scenario outline`_ parsed from a *feature file*.

    A scenario outline extends the existing :class:`~behave.model.Scenario`
    class with the addition of the :class:`~behave.model.Examples` tables of
    data from the *feature file*.

    The attributes are:

    .. attribute:: keyword

       This is the keyword as seen in the *feature file*. In English this will
       typically be "Scenario Outline".

    .. attribute:: name

       The name of the scenario (the text after "Scenario Outline:".)
github behave / behave / behave / reporter / junit.py View on Github external
* testcase.@name   = scenario.name
          * testcase.@status = scenario.status
          * testcase.@time   = scenario.duration

        Distinguishes now between failures and errors.
        Failures are AssertationErrors: expectation is violated/not met.
        Errors are unexpected RuntimeErrors (all other exceptions).

        If a failure/error occurs, the step, that caused the failure,
        and its location are provided now.

        :param scenario:  Scenario to process.
        :param report:    Context object to store/add info to (outgoing param).
        """
        # pylint: disable=too-many-locals, too-many-branches, too-many-statements
        assert isinstance(scenario, Scenario)
        assert not isinstance(scenario, ScenarioOutline)
        if scenario.status != Status.skipped or self.show_skipped:
            # -- NOTE: Count only if not-skipped or skipped should be shown.
            report.counts_tests += 1
        classname = report.classname
        feature = report.feature
        feature_name = feature.name
        if not feature_name:
            feature_name = self.make_feature_filename(feature)

        case = ElementTree.Element('testcase')
        case.set(u"classname", u"%s.%s" % (classname, feature_name))
        case.set(u"name", scenario.name or "")
        case.set(u"status", scenario.status.name)
        case.set(u"time", _text(round(scenario.duration, 6)))