White Box Testing

White box testing examines internal code structure, logic, and flow to find defects.

Explanation:

  • Requires programming knowledge to test control flow and data handling.
  • Covers unit testing, security testing, and branch coverage.
  • Performed by developers and security testers.

Example (Python Unit Test):

import unittest

def add(x, y):
return x + y

class TestAddition(unittest.TestCase):
def test_add(self):
self.assertEqual(add(2, 3), 5)

if __name__ == "__main__":
unittest.main()
  • This checks if add(2, 3) correctly returns 5.