Versions Compared

Key

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

Boundary value analysis is a type of black box or specification-based testing technique in which tests are performed using the boundary values. It's is worth testing boundary values because the input values near the boundary have higher chances of error. Whenever we do the testing by boundary value analysis, the tester focuses on, while entering boundary value whether the software is producing correct output or not.

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


Before the first test will be written let's think about boundary conditions in the get_triangle_area function. In the list below, we collected the majority of cases when code execution can end with some errors. 

  1. The input file doesn't exist.
  2. Bad input file extension.
  3. Empty input file.
  4. Bad value type (e.g. base and height can't be strings).
  5. A negative value of base or/and height.
  6. Call function without arguments.
  7. Base or height value bigger than 100 (in get_triangle_area function base and height values should be in range from 1 to 100).