Showing posts with label Simple Example. Show all posts
Showing posts with label Simple Example. Show all posts

Saturday, 10 November 2018

TDD with Python

Example to Demonstrate Test driven development using Python




#write a unite test to tst the method
"""doc sting
"""
import unittest

def simple_intrest(principle, rate, time):
    """this function compute simple interest
    """
    return (principle*rate*time)/100
def amount(principle, rate, time):
    """this function compute the amount on
    i.e  simple interest + principle
    """
    return principle+simple_intrest(principle, rate, time)
class TestBanking(unittest.TestCase):
    """ the is the test class
    """
    def test_simple_intrest(self):
        """ test simple intrest
        """
        self.assertEqual(simple_intrest(1000, 8, 1), 80)
        self.assertEqual(simple_intrest(100, 8, 1), 8)
        self.assertEqual(simple_intrest(-100, 8, 1), -8)
    def test_amount(self):
        """ test amount
        """
        self.assertEqual(amount(100, 8, 1), 108)
        self.assertEqual(amount(10, 8, 1), 10.8)

RUN_TEST = TestBanking()
#call test simple intrest function
RUN_TEST.test_simple_intrest()
#call test amount function
RUN_TEST.test_amount()

Apache Beam Learning In Java Tutorials

 Wow  https://youtu.be/9kGETU63rkc