Hi! So you want to learn TDD or get better at it? Great. For all the following Katas follow these rules exactly.
- Read the requirements carefully.
- Stick to the rules of TDD strictly.
- Do one step at a time.
- Don't look ahead.
You may want to use this Python unittest
template.
import unittest
# here goes your production code
class SomeTest(unittest.TestCase):
def test_fail(self):
self.fail()
def test_something(self):
self.assertTrue(True)
if __name__ == '__main__':
unittest.main()
You can now run your test like this:
$: python thatfile.py
Maybe you want to install watchdog
.
$: pip install watchdog
Now you can run your tests each time you save thatfile.py
.
$: watchmedo shell-command --patterns="*.py" --command="clear; python thatfile.py" .
Given we run a webshop and customers can compile an order consisting of several items, I want to calculate the total order amount.
- VAT needs to be applied
- postage is 5$
- orders above 50$ get free shipping
Write a program that counts the vowels in a string.
- Given some input string the number of vowels should be returned.
- Given some inut string the frequency of each vowel should be returned.
- Givem some input string the most-frequent vowel should be returned.
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
- Print numbers from 1 to 100
- Print "Fizz" instead of number which is divisible by 3
- Print "Buzz" instead of number which is divisible by 5
- Print "FizzBuzz" instead of number which is divisible by both 3 and 5