Exercise 47: Automated Testing

Having to type commands into your game over and over to make sure it's working is annoying. Wouldn't it be better to write little pieces of code that test your code? Then when you make a change, or add a new thing to your program, you just "run your tests" and the tests make sure things are still working. These automated tests won't catch all your bugs, but they will cut down on the time you spend repeatedly typing and running your code.

Every exercise after this one will not have a What You Should See section, but instead will have a What You Should Test section. You will be writing automated tests for all of your code starting now, and this will hopefully make you an even better programmer.

Ready To Learn To Code?

If you enjoyed the sample so far, then you can continue learning by purchasing Learn Python 2 The Hard Way, or Buying Learn Python 3 The Hard Way for 29.99. You'll receive all 52 exercises in PDF and HTML formats, plus videos teaching you each exercise. This course has helped 12 million people learn to code since 2010, so it can help you too. If you want to see more samples then try the Appendix A: Command Line Crash Course. If you already purchased this book then you can download the videos at account page or view the paid HTML version.

Need To Learn For Free?

My Learn Ruby The Hard Way is still free to read for anyone who needs to learn to code. Ruby is a perfectly fine alternative to Python, and works just as well as a first language. If you can't afford Learn Python The Hard Way then read Learn Ruby The Hard Way for free.

Buy The Python 2 Course

When you buy directly from the author, Zed A. Shaw, you'll get a professional quality PDF and hours of HD Video, all DRM-free and yours to download.

$29.99

Buy The Python 2 Course Buy The Python 3 Course Instead

Try a free sample of Learn Python the Hard Way right here, video lectures not included.