Software Engineering (2160701)

BE | Semester-6   Winter-2017 | 11/03/2017

Q4) (c)

Explain White Box Testing With an Example.

Black Box Testing

  • Also known as specification-based testing
  • Tester has access only to running code and the specification it is supposed to satisfy
  • Test cases are written with no knowledge of internal workings of the code
  • No access to source code
  • So test cases don’t worry about structure
  • Emphasis is only on ensuring that the contract is met
  • Black-box testing attempts to find errors in the following categories:
    • Incorrect or missing functions
    • Interface errors
    • Errors in data structures or external database access
    • Behavior or performance errors
    • Initialization and termination errors.

Advantages

  • Scalable; not dependent on size of code
  • Testing needs no knowledge of implementation
  • Tester and developer can be truly independent of each other
  • Tests are done with requirements in mind
  • Does not excuse inconsistencies in the specifications
  • Test cases can be developed in parallel with code

Disadvantages

  • Test size will have to be small
  • Specifications must be clear, concise, and correct
  • May leave many program paths untested
  • Weighting of program paths is not possible
 
 

Test Case Design

  • Examine pre-condition, and identify equivalence classes
  • All possible inputs such that all classes are covered
  • Apply the specification to input to write down expected output
Test Case Design

Equivalence Partitioning

  • Input data for a program unit usually falls into a number of partitions, e.g. all negative integers, zero, all positive numbers
  • Each partition of input data makes the program behave in a similar way
  • Two test cases based on members from the same partition is likely to reveal the same bugs
  • By identifying and testing one member of each partition we gain 'good' coverage with 'small' number of test cases
  • Testing one member of a partition should be as good as testing any member of the partition
  • Example: for binary search the following partitions exist
    • Inputs that conform to pre-conditions
    • Inputs where the precondition is false
    • Inputs where the key element is a member of the array
    • Inputs where the key element is not a member of the array
  • Pick specific conditions of the array
    • The array has a single value
    • Array length is even
    • Array length is odd

Boundary Value Analysis

  • Arises from the fact that most program fail at input boundaries
  • Suppose system asks for “a number between 100 and 999 inclusive”
  • The boundaries are 100 and 999
  • We therefore test for values
99 100 101
Lower Boundary
 
999 999 1000
Upper Boundary