

def _process_scenario(self, scenario, report):
    "\n        Process a scenario and append information to JUnit report object.\n        This corresponds to a JUnit testcase:\n\n          * testcase.@classname = f(filename) +'.'+ feature.name\n          * testcase.@name   = scenario.name\n          * testcase.@status = scenario.status\n          * testcase.@time   = scenario.duration\n\n        Distinguishes now between failures and errors.\n        Failures are AssertationErrors: expectation is violated/not met.\n        Errors are unexpected RuntimeErrors (all other exceptions).\n\n        If a failure/error occurs, the step, that caused the failure,\n        and its location are provided now.\n\n        :param scenario:  Scenario to process.\n        :param report:    Context object to store/add info to (outgoing param).\n        "
    assert isinstance(scenario, Scenario)
    assert (not isinstance(scenario, ScenarioOutline))
    if ((scenario.status != 'skipped') or self.show_skipped):
        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('classname', ('%s.%s' % (classname, feature_name)))
    case.set('name', (scenario.name or ''))
    case.set('status', scenario.status)
    case.set('time', _text(round(scenario.duration, 6)))
    step = None
    if (scenario.status == 'failed'):
        for status in ('failed', 'undefined'):
            step = self.select_step_with_status(status, scenario)
            if step:
                break
        assert step, ('OOPS: No failed step found in scenario: %s' % scenario.name)
        assert (step.status in ('failed', 'undefined'))
        element_name = 'failure'
        if isinstance(step.exception, (AssertionError, type(None))):
            report.counts_failed += 1
        else:
            report.counts_errors += 1
            element_name = 'error'
        failure = ElementTree.Element(element_name)
        step_text = self.describe_step(step).rstrip()
        text = ('\nFailing step: %s\nLocation: %s\n' % (step_text, step.location))
        message = _text(step.exception)
        failure.set('type', step.exception.__class__.__name__)
        failure.set('message', message)
        text += _text(step.error_message)
        failure.append(CDATA(text))
        case.append(failure)
    elif ((scenario.status in ('skipped', 'untested')) and self.show_skipped):
        report.counts_skipped += 1
        step = self.select_step_with_status('undefined', scenario)
        if step:
            report.counts_failed += 1
            failure = ElementTree.Element('failure')
            failure.set('type', 'undefined')
            failure.set('message', ('Undefined Step: %s' % step.name))
            case.append(failure)
        else:
            skip = ElementTree.Element('skipped')
            case.append(skip)
    stdout = ElementTree.Element('system-out')
    text = self.describe_scenario(scenario)
    if scenario.stdout:
        output = _text(scenario.stdout)
        text += ('\nCaptured stdout:\n%s\n' % output)
    stdout.append(CDATA(text))
    case.append(stdout)
    if scenario.stderr:
        stderr = ElementTree.Element('system-err')
        output = _text(scenario.stderr)
        text = ('\nCaptured stderr:\n%s\n' % output)
        stderr.append(CDATA(text))
        case.append(stderr)
    if ((scenario.status != 'skipped') or self.show_skipped):
        report.testcases.append(case)

dataset/ETHPy150Open behave/behave/behave/reporter/junit.py JUnitReporter._process_scenario/original