Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Boundary testing is the process of testing between extreme ends or boundaries between partitions of the input values. In this example, we will check the majority number of possible cases when exceptions can occur. For tutorial purposes let's write a function called get_triangle_area which returns triangle area calculated from base and height values read from input files (input files are function arguments). 


Code Block
languagepy
titleget_triangle_area()
def get_triangle_area(file_base, file_height):
    base = float(open(file_base, 'r').readline())
    height = float(open(file_height, 'r').readline())

    if base not in range(1, 100):
        raise ValueError()
    if height not in range(1, 100):
        raise ValueError()

    return 0.5 * base * height