You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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). 


get_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



  • No labels