Code Monkey home page Code Monkey logo

pytest-eucalyptus's Introduction

Eucalyptus - BDD plugin for Pytest

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

pypi pypi-versions builds docs coverage Quality Gate Status

pytest-eucalyptus has been built to feature the best of both worlds:

  • Aloe which implements great infrastructure and uses the original Gherkin parser.
  • pytest-bdd does not require a separate runner and benefits from the power and flexibility of Pytest.

Quick Start

  1. Create new module and add empty __init__.py.

  2. Install Pytest and Eucalyptus:

    pip install pytest pytest-eucalyptus
  3. Let's assume we are testing the following implementation of calculator.py:

        def add(*numbers):
            return sum(numbers)
  4. Write your first feature 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. Add the definitions in tests/conftest.py:

        from calculator import add
        from pytest_eucalyptus import before, step, world
    
    
        @before.each_example
        def clear(*args):
            """Reset the calculator state before each scenario."""
            world.numbers = []
            world.result = 0
    
    
        @step(r'I have entered (\d+) into the calculator')
        def enter_number(self, number):
            world.numbers.append(float(number))
    
    
        @step(r'I press add')
        def press_add(self):
            world.result = add(*world.numbers)
    
    
        @step(r'The result should be (\d+) on the screen')
        def assert_result(self, result):
            assert world.result == float(result)
  6. Run the code

$ 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 ===========================

Documentation

Please find more docs here.

License

Pytest-Eucalyptus is licensed under the Apache License 2.0 โ€“ see the LICENSE.md for specific details.

pytest-eucalyptus's People

Contributors

koterpillar avatar gabrielfalcao avatar danni avatar rickycook avatar adaschevici avatar offbeatful avatar andydeany avatar chris-morgan avatar fsouza avatar apieum avatar mitgr81 avatar benoitbryon avatar nikolas avatar wpjunior avatar systemparadox avatar hltbra avatar pokutnik avatar kevinastone avatar medwards avatar pshomov avatar davidsulc avatar algernon avatar jensrantil avatar kyleconroy avatar tscalzo000 avatar akaihola avatar tswicegood avatar rbu avatar rtkrruvinskiy avatar michelts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.