Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tdd with-python-and-django

1,360 views

Published on

Talk I gave at PyCon Sweden 2015

Published in: Software
  • Be the first to comment

Tdd with-python-and-django

  1. 1. Test Driven Development with Python and Django
  2. 2. Who the F**lavia?
  3. 3. Agenda 1. Good code and bad code 2. What is TDD? 3. Why TDD? 4. How to TDD? 5. Continuous Integration
  4. 4. good code and bad code
  5. 5. undead code
  6. 6. what is TDD?
  7. 7. why TDD?
  8. 8. testing for design
  9. 9. how to TDD?
  10. 10. “You are not allowed to write any production code unless it is to make a failing test pass.”
  11. 11. “You are not allowed to write any more of a test than is sufficient to fail; and compilation failures are failures.”
  12. 12. “You are not allowed to write any more production code than is sufficient to pass the one failing test.”
  13. 13. testing smells
  14. 14. def test_should_request_and_be_success(self): response = self.client.get(“/posts”) self.assertEqual(200, response.status_code)
  15. 15. def test_should_have_posts_on_ctx(self): response = self.client.get(“/posts”) self.assertIn(“posts”, response.context_data)
  16. 16. 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)
  17. 17. Tools ● unittest ● django.test.TestCase ● nose ● py.test ● ...
  18. 18. CI - Continuous Integration ● drone.io ● travisci ● circleci ● jenkins ● hudson ● ...
  19. 19. Tack så mycket! Flavia Missi @flaviamissi https://github.com/flaviamissi
  20. 20. Tack så mycket! ● http://butunclebob.com/ArticleS.UncleBob. TheThreeRulesOfTdd ● http://butunclebob.com/ArticleS.UncleBob. TheBowlingGameKata ● http://extremeprogramming.org/

×