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.
Test Driven Development in Python                         Anoop Thomas Mathew                  Agiliq Info Solutions Pvt. ...
Overview●   About TDD●   TDD and Python●   unittests●   Developing with Tests●   Concluding Remarks●   Open Discussion
“ Walking on water and developing software  from a specification are easy if both are  frozen. ” - Edward V Berard
About Test Driven Development           (TDD)●   Write tests for the use case●   Run it (make sure it fails and fails     ...
Advantages of TDD●   application is determined by using it●   written minimal amount of application code       –   total a...
Unittestimport unittestclass MyTest(unittest.TestCase):    def testMethod(self):        self.assertEqual(1 + 2, 3, "1 + 2 ...
import unittestfrom demo import Greater                              The Testclass DemoTest(unittest.TestCase):    def tes...
class Greater(object):                                           The Program    def greater(self, val1, val2):        if t...
Test Again1. Add new test for features/bugs2. Resolve the issue, make the test succeed.3. Iterate from Step 1
Beware!!!Murphy is everywhere.
Lets Discuss
Upcoming SlideShare
Loading in …5
×

Test Driven Development in Python

1,950 views

Published on

Published in: Technology, Business
  • Was a little hesitant about using ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ at first, but am very happy that I did. The writer was able to write my paper by the deadline and it was very well written. So guys don’t hesitate to use it.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/ZjCKm ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/ZjCKm ◀ ◀ ◀ ◀
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Test Driven Development in Python

  1. 1. Test Driven Development in Python Anoop Thomas Mathew Agiliq Info Solutions Pvt. Ltd.
  2. 2. Overview● About TDD● TDD and Python● unittests● Developing with Tests● Concluding Remarks● Open Discussion
  3. 3. “ Walking on water and developing software from a specification are easy if both are frozen. ” - Edward V Berard
  4. 4. About Test Driven Development (TDD)● Write tests for the use case● Run it (make sure it fails and fails miserably)● Write code and implement the required functionality with relevant level of detail● Run the test● Write test for addition features● Run all test● Watch it succeed. Have a cup of coffee !
  5. 5. Advantages of TDD● application is determined by using it● written minimal amount of application code – total application + tests is probably more – objects: simpler, stand-alone, minimal dependencies● tends to result in extensible architectures● instant feedback
  6. 6. Unittestimport unittestclass MyTest(unittest.TestCase): def testMethod(self): self.assertEqual(1 + 2, 3, "1 + 2 !=3")if __name__ == __main__: unittest.main()
  7. 7. import unittestfrom demo import Greater The Testclass DemoTest(unittest.TestCase): def test_number(self): comparator = Greater() result = comparator.greater(10,5) self.assertTrue(result) def test_char(self): comparator = Greater() result = comparator.greater(abcxyz, AB) self.assertTrue(result) def test_char_equal(self): comparator = Greater() result = comparator.greater(4, 3) self.assertTrue(result)if __name__ == __main__: unittest.main()
  8. 8. class Greater(object): The Program def greater(self, val1, val2): if type(val1) ==str or type(val2) == str: val1 = str(val1) val2 = str(val2) sum1 = sum([ord(i) for i in val1]) sum2 = sum([ord(i) for i in val2]) if sum1 > sum2: return True else: return False if val1>val2: return True else: return False
  9. 9. Test Again1. Add new test for features/bugs2. Resolve the issue, make the test succeed.3. Iterate from Step 1
  10. 10. Beware!!!Murphy is everywhere.
  11. 11. Lets Discuss

×