Wednesday, 13 April 2016

DD Path Testing: Test Cases

Concerning DD Path Testing, path coverage makes the most sense to cover as both statement and branch coverage are subsumed within path coverage. As I mentioned before, path testing mostly focuses on the graph rather than the logic of a program, concerning itself with what could happen rather than what should happen. As such, it results in many infeasible paths that could never be traversed due to the logic of the program.

Through much trial and error, I eventually narrowed down the number of possible paths to 16 which I shall explain below. Not all of these need be feasible, however whether these paths are feasible or not shall be discovered upon testing. The 16 possible paths are below and explained, although referencing the DD Path Graph in my previous post will be necessary. 

The sections contained within these brackets - () - are part of a while loop and could therefore have an infinite number of iterations. This would increase the number of paths so I shall simply assume these paths below will account for any number of iterations.
  1. Start-(A-B-A)-(D-E-D)-(G-H-J-K-L-G)-End
    • This path represents the most straightforward path, i.e. there is no prompting or exceptions.
  2. Start-(A-B-A)-(D-E-F-D)-(G-H-J-K-L-G)-End
    • This path occurs where the user input for a location is caught as an exception and is prompted for a new value.
  3. Start-(A-B-C-A)-(D-E-D)-(G-H-J-K-L-G)-End
    • Here the exception is caught for an incorrect input for the number of steps and prompts the user for a correct value.
  4. Start-(A-B-C-A)-(D-E-F-D)-(G-H-J-K-L-G)-End
    • This time, an incorrect input is caught for both the number of steps and a location and again, the same prompt appears.
  5. Start-(A-B-A)-(D-E-D)-(G-H-J-L-G)-End
    • Here the only difference is that the if statement is not true, i.e. that the largest difference has not changed, it is the same value for the gap.
  6. Start-(A-B-A)-(D-E-F-D)-(G-H-J-L-G)-End
    • The user has given an incorrect value for the location and the value of the gap has not changed.
  7. Start-(A-B-C-A)-(D-E-D)-(G-H-J-L-G)-End
    • Similar to before, the user inputted an unaccepted value for the number of steps and the value of the gap is unchanged.
  8. Start-(A-B-C-A)-(D-E-F-D)-(G-H-J-L-G)-End
    • Both values for the steps and location is incorrect and the value of the gap is unchanged.
  9. Start-(A-B-A)-(D-E-D)-(G-H-I-G)-End
    • Here within the third while loop of the program, the user has given an incorrect value for a location.
  10. Start-(A-B-A)-(D-E-F-D)-(G-H-I-G)-End
    • Again an incorrect value has been inputted for the location for the second and third loops of the program.
  11. Start-(A-B-F-A)-(D-E-D)-(G-H-I-G)-End
    • An incorrect value for the number of steps and for a location within the third loop prompts the user for a valid input on both accounts.
  12. Start-(A-B-C-A)-(D-E-F-D)-(G-H-I-G)-End
    • Invalid value for number of steps and locations in both the second and third while loops of the program.
  13. Start-(A-B-A)-(D-E-D)-G-End
    • Here the program does not execute the third loop at all due to a value given by the user, e.g. most likely a 0 or a 1 considering our program.
  14. Start-(A-B-A)-(D-E-F-D)-G-End
    • Again the third loop is not executed due to a value inputted by the user and a value of a location is also invalid.
  15. Start-(A-B-F-A)-(D-E-D)-G-End
    • Third loop is not executed and the value for number of steps is invalid and the user is prompted to try again.
  16. Start-(A-B-C-A)-(D-E-F-D)-G-End
    • Number of steps and location values are both invalid and the third while loop is not executed.
Naturally, we can see straight away that some of these paths are not feasible at all, considering the program will continue to prompt you until you give it the correct input. However, we shall see the results of these tests once I begin my testing with the above test cases. I will include more test cases to satisfy my own curiosity in finding errors in the program as I test, but the above 16 shall be my basis for testing for now.