bdd的pytest插件

pytest-eucalyptus的Python项目详细描述


Eucalyptus-Pytest的bdd插件

A nice fork of Aloe. Migrated from Nose to Pytest.

pypipypi-versionsbuildsdocscoverage

pytest eucalyptus已构建为具有两个世界的最佳特性:

  • Aloe它实现了很好的基础结构并使用了原始的小黄瓜解析器。
  • pytest-bdd不需要单独的转轮,并且得益于PyTest的功率和灵活性。

快速启动

  1. 创建新模块并添加空的__init__.py

  2. 安装pytest和eucalyptus:

    pip install pytest pytest-eucalyptus
    
  3. 假设我们正在测试calculator.py的以下实现:

    defadd(*numbers):returnsum(numbers)
  4. 编写第一个功能tests/calculator.feature

        Feature: Add up numbers
    
        As a mathematically challenged user
        I want to add numbers
        So that I know the total
    
        Scenario: Add two numbers
            Given I have entered 50 into the calculator
            And I have entered 30 into the calculator
            When I press add
            Then the result should be 80 on the screen
    
  5. tests/conftest.py

    中添加定义
    fromcalculatorimportaddfrompytest_eucalyptusimportbefore,step,world@before.each_exampledefclear(*args):"""Reset the calculator state before each scenario."""world.numbers=[]world.result=0@step(r'I have entered (\d+) into the calculator')defenter_number(self,number):world.numbers.append(float(number))@step(r'I press add')defpress_add(self):world.result=add(*world.numbers)@step(r'The result should be (\d+) on the screen')defassert_result(self,result):assertworld.result==float(result)
  6. 运行代码

    $ pytest
============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-4.6.3, py-1.8.0, pluggy-0.12.0
rootdir: /Users/eucalyptus-user/src/test
plugins: eucalyptus-0.3.0
collected 1 item                                                               

calculator.feature .                                                     [100%]

=========================== 1 passed in 0.01 seconds ===========================

文档

请查找更多文档here

许可证

pytest eucalyptus是在apache许可证2.0下获得许可的,请参见LICENSE.md了解具体的详细信息。

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

推荐PyPI第三方库


热门话题
java我需要在一个数组中添加1000个介于1和100之间的整数及其出现次数,然后显示它们   如何在java中将两个不同的excel文件作为数据库连接到同一台服务器上?   java JSP编译错误令牌“throws”语法错误,应为throw   java如何使用Jetty HTTP客户端和MultiPartContentProvider上载BuffereImage?   具有多个方法对象的java测试类   在java中比较字符串和打印剩余字符时出现意外输出?   java设置JPanel的大小,当其中没有组件时   使用exoplayer播放m3u8文件的java   JSON中未添加Jackson@type的java Rest JSON   java如何为heroku创建procfile文件?   基于数组的java信息存储   sockets java。网SocketTimeoutException:在Tomcat下读取超时   安卓x的java问题。偏爱安卓工作室   java我的方法没有按预期运行   java如何通过单击单选按钮将值从表传递到servlet?   java无法获取instagram个人资料图片的完整大小