how to make a test driven development environment part 1

what is Test Driven Development (TDD)?

This is a way to write software with a focus on tests. I write tests for ideas to reach a goal or meet a requirement, and the results tell me if I am closer to the goal or not. I repeat the process until I get to the goal.

what is a Test Driven Development Environment?

A Test Driven Development environment is a group of files and folders in a project where I can write tests and code and they automatically run so I see the results immediately.

what is the Test Driven Development cycle?

The Test Driven Development cycle is RED GREEN REFACTOR

  • RED: make it fail - write a test that fails to make sure the test works

  • GREEN: make it pass - write the simplest thing that will make the failing test pass

  • REFACTOR: make it better - write a better solution, test or both, usually by removing duplication

This process can be repeated as many times as needed until I get to my goal.

preview

I set up an environment for every Python project, this way I keep all the things that belong to the project in the same place. I can do this manually, which means I have to do the same exact steps for every project or I could do it automatically where I give the computer a command and it does all those steps for me.

Some things I think about when I want to start a project

  • What name will I give the project? this is based on what the project will do. It’s also one of the hardest things to do

  • What is the structure of the project? - What files and folders does the project need?

  • What other programs does my project need?

  • What tests am I going to write for this project?

It turns out some of this is the same for every project

  • I give the project a name

  • I make a new folder for the project with the name I gave it

  • I place the code for the project in a src folder

  • I place the tests for the project in a tests folder

  • I try to name everything in the project with the name of the project or with something that describes what it does

  • I write what programs the project needs (its dependencies) in a requirements file

  • I make a virtual environment to keep the dependencies separate from the rest of the computer

  • I install what the project needs in the virtual environment

  • I work in the virtual environment

  • I run automated tests to make sure I have a Test Driven Development environment

  • I start writing code for the project

Here is what that structure looks like if the name of the project is PROJECT_NAME

PROJECT_NAME
├── requirements.txt
├── src
   └── PROJECT_NAME.py
└── tests
    └── test_PROJECT_NAME.py

what is covered?

what is covered?

These chapters show how I setup a project in Python on any computer (Linux, Windows, MacOS) to help you get started with Test Driven Development right now

on Linux, MacOS and Windows with Window Subsystem for Linux computers

On Windows computers without Windows Subsystem for Linux


at the end of the chapter you will know how to make a Python Test Driven Development project for MacOS, Linux, Windows Subsystem for Linux or Windows without Windows Subsystem for Linux


what is next?