how to make a test driven development environment¶
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.
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 pick a name for the project
I make a new folder for every project with the name I picked
I place the code for the project in a
srcfolderI place the tests for the project in a
testsfolderI 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
└── PROJECT_NAME.py
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
they cover the following
on Linux, MacOS and Windows with Windows Subsystem for Linux computers
how to manually make a python test driven development environment
how to automatically make a python test driven development environment
how to see what packages are installed in a virtual environment
On Windows computers without Windows Subsystem for Linux
how to make an empty file on Windows without Windows Subsystem for Linux
how to write text to a file on Windows without Windows Subsystem for Linux
how to run a Python program on Windows without Windows Subsystem for Linux
how to automatically run tests on Windows without Windows Subsystem for Linux
how to activate a virtual environment on Windows without WSL
how to deactivate a virtual environment on Windows without WSL
how to write text to a file on Windows without Windows Subsystem for Linux
how to install Python packages in a virtual environment on Windows without WSL
how to see what packages are installed in a virtual environment on Windows without WSL
how to view all the commands I typed in a terminal on Windows without WSL
at the end you will have these programs to automatically setup a Python Test Driven Development project
makePythonTdd.sh - for MacOS, Linux and Windows Subsystem for Linux
makePythonTdd.ps1 - for Windows without Windows Subsystem for Linux