Git Product home page Git Product logo

python-tdd-kata-starter's Introduction

Test-Driven Development Kata Starter Project

This project is intended to give developers a simple starting point to practice Test-Driven Development (TDD) using katas. Learning to practice TDD is not like learning a framework or a library. When learning to use a library, you read the docs and sample code and then you're either able to use the library successfully, or you're not. TDD, on the other hand, is a practice: it is not about what you're doing as much as it is about how you're doing it.

What is Test-Driven Development?

Though TDD can apply to a number of different types of tests, this project focuses on applying TDD to writing unit tests. While unit testing often involves writing tests after the software is complete, TDD involves writing tests before writing the software that is to be tested. Another way of explaining this approach would be to say that unit tests and software are developed together, but the unit tests are often a step ahead of the software itself. If you're unfamiliar with TDD, the idea of writing tests before writing software might seem odd. Uncle Bob's "Three Rules of TDD" captures the workflow very succinctly:

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.
  2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

Introductory Reading

These are short. You should read them; I'll wait:

What's in This Project

The project features a minimal setup to allow you to quickly start practicing TDD katas using Python and pytest.

  • reqiurements.txt: Install the project's requirements/dependencies with pip install -r requirements.txt.
  • pytest.ini: This configuration tells pytest where to find both source and test files so.
  • src/string_calculator.py and test/string_calculator_test.py: Starter files for the String Calculator kata

Commands

All of these commands can be run at the root of the project.

  • pytest: run all tests
  • pytest --cov=src: run all tests and produce a test coverage report. This is certainly not necessary for learning TDD, but it can be interesting to understand how complete your unit tests are.
  • ptw: starts pytest-watch which will automatically run all tests any time a file in the project has changed. While this is not necessary for learning TDD, I have found that tools like this add to the enjoyment of practicing TDD.

What's Not in This Project

Mocking libraries like mockito have been intentionally excluded. While learning to leverage powerful mocking libraries is an important part of learning to write properly-isolated unit tests, that is not the goal of this project.

What Should I Do Now?

Clone or fork this project and make it your own! You can complete the starter String Calculator files, or you can delete them and create your own. Obviously, you can add files and start practicing other katas. If you're looking for more, this blog post contains a nice list; Google will help you find plenty more.

python-tdd-kata-starter's People

Contributors

btgrant-76 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.