Python Classroom Series – 23/Sept/2020

Who this unit testing is for

  • Developers
  • Testers
  • Developers


  • Test suites
  • Test Cases
  • Test Fixture
  • Test Runner
  • Regression

Sample Test

  • Using python’s built in module unittest
import unittest

from mynumber import MyNumber

class TestMyNumber(unittest.TestCase):

    def test_is_even_positive(self):
        This method is used to test even or odd functionality
        my_number = MyNumber()  # Arrange
        result = my_number.is_even(10)  # Action
        self.assertEqual(result, True)  # Assert

    def test_is_even_negative(self):
        This will test the is_even method with odd value
        my_number = MyNumber()
        result = my_number.is_even(11)
        self.assertEqual(result, False)

    @unittest.skip("Work In Progress")
    def test_is_even_negative_boundary(self):
        my_number = MyNumber()
        result = my_number.is_even('hello')

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin