Esempio n. 1
0
    def setUp(self):
        # setUp() method to create a local instance of the class

        # setUp() also used to establish test fixtures for all tests, i.e.
        # resources/libaries/connections and imports needed for said tests
        # setUp() to configure fixtures
        # tearDown() to clean up fixtures at end of unit test
        self.func = BasicFunction()
class TestBasicFunction(unittest.TestCase):
    def setUp(self):
        self.func = BasicFunction()

    def test_1(self):
        self.assertEqual(self.func.state, 0)

    def test_2(self):
        self.func.increment_state()
        self.assertEqual(self.func.state, 1)

    def test_3(self):
        self.func.increment_state()
        self.func.clear_state()
        self.assertEqual(self.func.state, 0)
Esempio n. 3
0
class TestBasicFunction(unittest.TestCase):

    def setUp(self):
        self.func = BasicFunction()

    def test_canary(self):
        self.assertTrue(True)

    def test_default_state(self):
        self.assertEqual(self.func.state, 0)

    def test_increment(self):
        self.func.increment_state()
        self.assertEqual(self.func.state, 1)

    def test_reset(self):
        self.func.increment_state()
        self.func.increment_state()
        self.func.clear_state()
        self.assertEqual(self.func.state, 0)
Esempio n. 4
0
class TestBasicFunction(unittest.TestCase):
    def setUp(self):  # method to create a local instance of this class
        self.func = BasicFunction()

    def test_1(self):
        self.assertTrue(True)

    def test_2(self):
        self.assertTrue(True)

    def test_3(self):
        self.assertEqual(self.func.state, 0)

    def test_4(self):
        self.func.increment_state()
        self.assertEqual(self.func.state, 1)

    def test_5(self):
        self.func.increment_state()
        self.func.increment_state()
        self.func.clear_state()
        self.assertEqual(self.func.state, 0)
Esempio n. 5
0
class TestBasicFunction(unittest.TestCase):
    def setUp(self):
        # setUp() method to create a local instance of the class

        # setUp() also used to establish test fixtures for all tests, i.e.
        # resources/libaries/connections and imports needed for said tests
        # setUp() to configure fixtures
        # tearDown() to clean up fixtures at end of unit test
        self.func = BasicFunction()

    # def test_fail(self):
    #     # desired outcome produces result that can be evaluated as false ---> use assertFalse()
    #     self.assertTrue(False,'failure message goes here - assertTrue is False for test_fail()')

    # def test_1(self):
    #     self.assertTrue(True)

    def test_2(self):
        # Case to check that class object state assignment is mutable with None assignment
        # upon new initialization of class obj
        self.func.state = None
        self.assertIsNone(self.func.state, None)

    def test_3(self):
        # unit test to check for initialization of local class
        self.assertEqual(self.func.state, 0, '0-state init check - pass')

    def test_4(self):
        self.func.increment_state()
        self.assertEqual(self.func.state, 1)

    def test_5(self):
        self.func.increment_state()
        self.func.increment_state()
        self.func.clear_state()
        self.assertEqual(self.func.state, 0)

    def test_6(self):
        # Test case using both increment_state() and decrement_state() that should result in 2
        self.func.increment_state()
        self.func.increment_state()
        self.func.increment_state()
        self.func.decrement_state()
        self.assertEqual(self.func.state, 2)
Esempio n. 6
0
 def setUp(self):
     self.func = BasicFunction()
Esempio n. 7
0
 def setUp(self):  # method to create a local instance of this class
     self.func = BasicFunction()