python-behave

Behave: How to import steps from another file?

好久不见. 提交于 2019-12-05 13:33:11
I have just started using behave , a Pythonic BDD framework using Gherkin syntax . behave takes a feature, e.g.: Scenario: Calling the metadata API Given A matching server When I call metadata Then metadata response is JSON And response status code is 200 And a steps file, e.g.: ... @then('response status code is {expected_status_code}') def step_impl(context, expected_status_code): assert_equals(context.response.status_code, int(expected_status_code)) @then('metadata response is JSON') def step_impl(context): json.loads(context.metadata_response.data) ... And combines them to a beautiful test

Handling Exceptions in Python Behave Testing framework

依然范特西╮ 提交于 2019-12-05 03:45:40
I've been thinking about switching from nose to behave for testing (mocha/chai etc have spoiled me). So far so good, but I can't seem to figure out any way of testing for exceptions besides: @then("It throws a KeyError exception") def step_impl(context): try: konfigure.load_env_mapping("baz", context.configs) except KeyError, e: assert (e.message == "No baz configuration found") With nose I can annotate a test with @raises(KeyError) I can't find anything like this in behave (not in the source, not in the examples, not here). It sure would be grand to be able to specify exceptions that might be

Skip a behave step in the step implementation

梦想的初衷 提交于 2019-12-05 02:05:12
Is there a way to tell behave in a step implementation to skip the current step? Something like: @given("bla bla bla") def step(): skip_current_step() The use case is that I want to check if some additional software is installed. If not, I want the complete scenario to be skipped. I don't know if you can skip from inside of a step, but you can skip a whole scenario at feature level: def before_feature(context, feature): is_software_installed = some_foo_magic() if not is_software_installed: for scenario in feature.scenarios: if depends_on_software(scenario): scenario.mark_skipped() Feature ,

how to pass variable argument to context.execute_steps in python-behave

非 Y 不嫁゛ 提交于 2019-12-01 12:58:08
问题 I want to execute certain step before executing my function. The step takes variable as an argument. I am not able to pass it in context.execute_steps. eg. call1 = "version" call1_method = "get" context.execute_steps('''When execute api{"method":call1_method, "call":call1}''') however this does not work. I get error in argument parsing because variables are not in quotes. I don't see any such example in behave documentation. Any help would be really appreciated. 回答1: There's a bunch of stuff

How to generate reports in Behave-Python?

落花浮王杯 提交于 2019-11-29 07:42:13
For Java there are external report generation tools like extent-report,testNG. The Junit produces the xml format output for individual feature file. To get a detailed report, I don't see an option or wide approach or solution within the Behave framework. How to produce the reports in Behave, do any other tools or framework needs to be added for the report generation in Behave? Chong Because my automations which using behave are all running on Jenkins so I can use the Jenkins plugin to display my junit report. I think this question might help you: How can I generate an HTML report for Junit

How can I see print() statements in behave (BDD)

南笙酒味 提交于 2019-11-28 05:16:04
Context: I am using Python with Behave (BDD). Whether I run my tests from the command line (behave) or from a custom main(), the behavior is the same: the test runs and the only output that I see in the console is the standard BDD report. My tests include print() statements that help me debug my code. However, none of these print statements are being displayed in the console output when I run behave. Is there any way we can have "behave" display the print statements in our code? My Main() config = Configuration() if not config.format: default_format = config.defaults["default_format"] config

How to generate reports in Behave-Python?

一世执手 提交于 2019-11-28 01:18:00
问题 For Java there are external report generation tools like extent-report,testNG. The Junit produces the xml format output for individual feature file. To get a detailed report, I don't see an option or wide approach or solution within the Behave framework. How to produce the reports in Behave, do any other tools or framework needs to be added for the report generation in Behave? 回答1: Because my automations which using behave are all running on Jenkins so I can use the Jenkins plugin to display

How can I see print() statements in behave (BDD)

梦想的初衷 提交于 2019-11-27 00:51:25
问题 Context: I am using Python with Behave (BDD). Whether I run my tests from the command line (behave) or from a custom main(), the behavior is the same: the test runs and the only output that I see in the console is the standard BDD report. My tests include print() statements that help me debug my code. However, none of these print statements are being displayed in the console output when I run behave. Is there any way we can have "behave" display the print statements in our code? My Main()