行为是行为驱动的开发,python风格

behave的Python项目详细描述


Travis CI Build StatusDocumentation StatusLatest VersionDownloadsLicenseJoin the chat at https://gitter.im/behave/behave

行为是行为驱动的开发,python风格。

logo

行为驱动开发(bdd)是一种敏捷的软件开发。 鼓励开发人员、qa和 软件项目中的非技术或商业参与者。

behave使用由python支持的自然语言风格编写的测试 代码。

首先,install *behave*.

现在创建一个名为“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: Showing 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

现在,继续阅读,学习如何充分利用behave。为了开始, 我们建议使用tutorial,然后使用feature testing languageapi引用。

更多信息

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带Maven的Eclipse Java存储库:缺少工件:compile   java如何以编程方式停止RMI服务器并通知所有客户端   java Roboguice抛出ClassNotFoundException:AnnotationDatabaseImpl   java为什么lucene 4.0删除IndexWriter类的两个构造函数?   nls如何避免java项目上不需要的日志消息?   测试无法在Selenium Webdriver(java)中定位iframe   使用XML的java servlet   java如何使用jxl用****屏蔽单元格   java使用SQLite从数据库中选择“没有这样的列”   导入扫描程序后出现java编译错误   插入查询的java空指针异常   使用创建PostgreSQL数据库。Java应用中的sql脚本   java使用jsoup将HTML解析为格式化的明文