Example #1
0
def test_step_should_fail_with_failed_state_and_report():
    """When a Step is failed it should change its State to FAILED and create a report"""
    # given
    step = Step(1, "keyword", "used_keyword", "text", None, None, None, None)

    # when
    try:
        raise Exception("buuh!")
    except Exception as exc:
        step.fail(exc)

    # then
    assert step.state is State.FAILED
    assert isinstance(step.failure_report, StepFailureReport)
Example #2
0
def test_step_fail_if_step_impl_func_raises(mocker):
    """A Step should fail if the Step Implementation function raised an Exception"""
    # given
    step = Step(1, "keyword", "used_keyword", "text", None, None, None, None)
    step.fail = mocker.MagicMock(name="Step fail function")
    step_impl_mock = mocker.MagicMock(name="Step Impl")
    exception = Exception("buuh!")
    step_impl_mock.func.side_effect = exception
    step_impl_match_mock = mocker.MagicMock(name="Step Impl Match")
    step_impl_match_mock.evaluate.return_value = ([], {})
    step.assign_implementation(step_impl_mock, step_impl_match_mock)

    # when
    step.run(None)

    # then
    step.fail.assert_called_once_with(exception)