Test Driven Development with Python and Django
Jul 19, 2015
“You are not allowed to write any more of a test than is sufficient to fail; and compilation failures are failures.”
“You are not allowed to write any more production code than is sufficient to pass the one failing test.”
def test_should_request_and_be_success(self): response = self.client.get(“/posts”) self.assertEqual(200, response.status_code)
def test_should_have_posts_on_ctx(self): response = self.client.get(“/posts”) self.assertIn(“posts”, response.context_data)
def test_should_list_posts_in_chronological_order(self): r = self.client.get(“/posts”) expected_posts = [p1, p2, p3, p4] # keep the order self.assertQuerySetEqual(r.context_data[“posts”], expected_posts)
Tack så mycket!
Flavia Missi@flaviamissihttps://github.com/flaviamissi
Tack så mycket!
● http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd
● http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
● http://extremeprogramming.org/