I discovered one such gap in my study of programming in general, and Python in particular, a number of months ago when I came across a quote online that went something like this: “Code that is not tested is broken by definition.†Testing? “You mean running the code to see if it works?†I thought to myself. Within the next hour I had my first exposure to the method of test-driven development and the Python unittest module.
This was literally the exact opposite of how I had approached my own programming projects up until then, which might be termed “error-driven developmentâ€: write some code; run it; see if it works; if it doesn’t work, tinker at random until it does; write some more code and repeat. I quickly realized that, according to the above quote, all my code was broken, by definition.
The test-driven development model is the reverse of this: write a test, run it and watch it fail; write some code to make the test pass; refactor; write another test and repeat. It was an enlightening experience to attempt writing even a simple program under a test-driven model, as it was immediately obvious that I had only the vaguest notions about things that I thought I knew fairly well.
Since then, I’ve re-written a number of programs I’d created for myself under a completely test-driven developmental model, and have integrated testing into my everyday coding practice. I’ve also collected a bunch of resources that I've found helpful along the way, which you can find below. Also, as you may know, of late there has been something of a controversy brewing on the merit and value of test driven software development. Some links on this are supplied at the end. As always, further recommendations are welcome in the comments!
Overview of Test-Driven Development (Video Lectures)
- Understanding Test Driven Development
- Unit Testing Best Practices
- Test Driven Development: That's Not What We Meant (Critical review of TDD practice)
Unit Testing in Python (Video Lectures)
Python Unittest Module Docs
Python Unittest Intro Tutorials
- Dive Into Python: Unit Testing
- Dive Into Python 3: Unit Testing
- Learn Python the Hard Way: Automated Testing
- Introduction to Unit Testing in Python and Ruby
- Introduction to Unittest
- Unittest Introduction
- Unit Testing with Python
- Improve Your Python: Understanding Unit Testing
- Testing Python Command Line Apps
Test Driven Development in Python
- TDD in Python in Five Minutes
- Beginning Test Driven Development in Python
- Unit Testing and TDD in Python
- Test Driven Development in Python Part 1
- Test Driven Development in Python Part 2
Unit Testing Today
- Is TDD Dead?
- Is Test Driven Development Dead?
- TDD is Dead. Long Live Testing!
- Examining the 'TDD is Dead' Controversy
Source:http://blog.agupieware.com/2014/07/unit-testing-and-test-driven.html
Tidak ada komentar:
Posting Komentar