behave是行为驱动的开发,python风格,behave-py3是一个支持python 3的个人分支,希望能合并回上游。
behave-py3的Python项目详细描述
行为是行为驱动的开发,python风格。
行为驱动开发(bdd)是一种敏捷的软件开发。 鼓励开发人员、qa和 软件项目中的非技术或商业参与者。
behave使用由python支持的自然语言风格编写的测试 代码。
现在创建一个名为“features/”的目录。 在该目录中创建一个名为“example.feature”的文件,其中包含:
# -- FILE: features/example.featureFeature: Showing off behave Scenario: Run a simple test Given we have behave installed When we implement 5 testsThen behave will test them for us!
创建一个名为“features/steps/”的新目录。 在该目录中创建一个名为“example_steps.py”的文件,其中包含:
# -- FILE: features/steps/example_steps.pyfrombehaveimportgiven,when,then,step@given('we have behave installed')defstep_impl(context):pass@when('we implement {number:d} tests')defstep_impl(context,number):# -- NOTE: number is converted into integerassertnumber>1ornumber==0context.tests_count=number@then('behave will test them for us!')defstep_impl(context):assertcontext.failedisFalseassertcontext.tests_count>=0
跑步行为:
$ behave Feature: Showin off behave # features/example.feature:2 Scenario: Run a simple test# features/example.feature:4 Given we have behave installed # features/steps/example_steps.py:4 When we implement 5 tests # features/steps/example_steps.py:8 Then behave will test them for us! # features/steps/example_steps.py:13 1 feature passed, 0 failed, 0 skipped 1 scenario passed, 0 failed, 0 skipped 3 steps passed, 0 failed, 0 skipped, 0 undefined
现在,继续阅读,学习如何最大限度地行为。为了开始, 我们推荐tutorial和feature testing language以及 api引用。
更多信息
- behave documentation(latest changes)
- behave.example:行为示例和教程(文档、可执行示例)。
测试域
behave和其他bdd框架允许您提供step库 在解决相同问题的类似项目中重用步骤定义 问题域。
目前已知支持以下测试域:
Testing Domain | Name | Description |
---|---|---|
Command-line | behave4cmd | Test command-line tools, like behave, etc. (coming soon). |
Web Apps | django-behave | Test Django Web apps with behave. |
Web, SMS, … | behaving | Test Web Apps, Email, SMS, Personas (step library). |