Giter Club home page Giter Club logo

lab-flask-bdd's Introduction

Lab: Python Flask Behavior Driven Development

Build Status Codecov

This repository is part of lab for the NYU DevOps class for Spring 2017, CSCI-GA.3033-013 on Behavior Driven Development with Flask and Behave

The sample code is using Flask microframework and is intented to test the Python support on IBM's Bluemix environment which is based on Cloud Foundry. It also uses Redis as a database for storing JSON objects.

Introduction

One of my favorite quotes is:

โ€œIf it's worth building, it's worth testing. If it's not worth testing, why are you wasting your time working on it?โ€

As Software Engineers we need to have the discipline to ensure that our code works as expected and continues to do so regardless of any changes, refactoring, or the introduction of new functionality.

This lab introduces Test Driven Development using PyUnit and nose. It also explores the use of using RSpec syntax with Python through the introduction of noseOfYeti and expects as plug-ins that make test cases more readable.

It also introduces Behavior Driven Development using Behave as a way to define Acceptance Tests that customer can understand and developers can execute!

Setup

For easy setup, you need to have Vagrant and VirtualBox installed. Then all you have to do is clone this repo and invoke vagrant:

git clone https://github.com/nyu-devops/lab-flask-bdd.git
cd lab-flask-bdd
vagrant up && vagrant ssh
cd /vagrant

You can now run behave and nosetests to run the BDD and TDD tests respectively.

Manually running the Tests

Run the tests using behave

$ behave

Run the tests using nose

$ nosetests

Nose is configured to automatically include the flags --with-spec --spec-color so that red-green-refactor is meaningful. If you are in a command shell that supports colors, passing tests will be green while failing tests will be red.

What's featured in the project?

* ./app/server.py -- the main Service using Python Flask
* ./tests/test_server.py -- unit test cases for the server
* ./tests/test_pets.py -- unit test cases for the model
* ./features/pets.feature -- Behave feature file
* ./features/steps/steps.py -- Behave step definitions

John Rofrano, Adjunct Professor, NYU

lab-flask-bdd's People

Contributors

rofrano avatar

Watchers

James Cloos avatar Matthew Chiappa 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.