How do I write a program out of provided unittest
<p>I have a unittests for a program. Being new to test driven development, how can I generate a program from the given tests</p>

<p>For example I have this test:</p>

<pre><code>class MaxMinTest(TestCase):
"""docstring for MaxMinTest"""

def test_find_max_min_four(self):
    self.assertListEqual([1, 4],
                         find_max_min([1, 2, 3, 4]),
                         msg='should return [1,4] for [1, 2, 3, 4]')

def test_find_max_min_one(self):
    self.assertListEqual([4, 6],
                         find_max_min([6, 4]),
                         msg='should return [4, 6] for [6, 4]')

def test_find_max_min_two(self):
    self.assertListEqual([2, 78],
                         find_max_min([4, 66, 6, 44, 7, 78, 8, 68, 2]),
                         msg='should return [2, 78] for [4, 66, 6, 44, 7, 78, 8, 68, 2]')

def test_find_max_min_three(self):
    self.assertListEqual([1, 4],
                         find_max_min([1, 2, 3, 4]),
                         msg='should return [1,4] for [1, 2, 3, 4]')

def test_find_max_min_identity(self):
    self.assertListEqual([4],
                         find_max_min([4, 4, 4, 4]),
                         msg='Return the number of elements in the list in a new list if the `min` and `max` are equal')
</code></pre>

<p>Thanks in advance. Please also share resources for learning test driven development for a beginner like me.</p>

<p>Without giving you the answer to the code that would make these tests pass, your approach can be something like this:</p>

<ul>
<li><p>What are you testing? </p></li>
<li><p>What does this function take, and what does it return?</p></li>
<li><p>How do I make <strong>one</strong> test pass? Once I make one test pass, how do I make the other test pass, while ensuring the previous test still passes. And so on, until all tests pass with the code you have written in your function. </p></li>
</ul>

<p>So, to answer your questions at a high level. </p>

<p>You are testing something that is called <code>MinMax</code>, which hints out at finding the minimum and maximum of something. This <em>something</em> is a function called <code>find_max_min</code> takes as input a <code>list</code>, and returns a list with two values. These two values are in order, the <code>min</code> and the <code>max</code> of the <code>list</code> you are passing to your function. </p>

<p>Documentation to look at: </p>

<ul>
<li><p><a href="https://docs.python.org/3/library/unittest.html" rel="nofollow">Official documentation on the unittest module in Python 3</a></p></li>
<li><p><a href="http://docs.python-guide.org/en/latest/writing/tests/" rel="nofollow">Tutorial on unittesting</a></p></li>
<li><p><a href="http://python-3-patterns-idioms-test.readthedocs.io/en/latest/UnitTesting.html" rel="nofollow">Unittesting and TDD</a></p></li>
</ul>

python python-2.7 unit-testing tdd