Tuesday, October 30, 2012

Designing Test Cases with 100% Coverage in a nutshell

I, in the recent past worked in a project which used the TMAP process for creating test cases.
It was definitely one of the best ways of creating test cases whose coverage was simply put 100%. We had used both White box and Black box techniques for deriving the test cases.

So though would share my experience with you all.



Introduction:

Testing is the most new kid in the block. This term is perhaps not very true, but true in the sense of implementation and recognition of testing as a practice in most of the organizations.
The earliest mention of software testing is found in 1967 in IBM white paper Evaluation of the Functional Testing of Control Programs William Elmendorf calls for a disciplined approach to software testing. Soon after this Software Engineering was introduced by a study group founded by NATO.
Looking back at the way this field has covered it has indeed made headway. Testing has diversified in the last decade into many domains and technologies. This decade we might witness the thinning of the line between White and Black box testing methodologies.
Almost Every aspect of testing has undergone changes except test design methodology. When we speak about test case design techniques two things that come to mind are Equivalence Class Partitioning and Boundary Value Analysis. These are well proven methodologies but they suffice only the functional part; what about the coverage? Can Traceability Matrix take care of that?

Traditional Test Case Design Techniques

I think now the focus is more on trying to uncover defects. In most of the cases in complex and big application this has been one of the pain points. Testers who write these cases fail to look at the coverage part which comes to highlight only when making the traceability matrix.
In General Test case design in broadly classified in two categories:
Black box (functional)
White box (structural)
Other
Specification derived tests
Equivalence partitioning
Boundary value analysis
State-transition testing
Branch testing
Condition testing
Data definition-use testing
Internal boundary value testing
Error guessing

Test Case Design using White box techniques

Test case design technique could use few techniques from White Box testing for deriving a very robust test suite.
Cyclomatic complexity for long has been used in white box testing only, but this can be effective used by testers to come to a conclusion to a minimum number to test cases to be written for a particular functionality as well as go on to derive different scenarios and then subsequently derive test cases from these scenarios.
  • It is a more effective way to detect defects than e.g. ad-hoc test cases.
  • The tests are reproducible because the order and content of the test execution are described in detail.
  • The standardized method ensures that the test process is independent of the individual who specifies and executes the test cases.
  • The standardized method ensures that the test specifications are transferable and maintainable.
  • It becomes easier to plan and manage the test process because the processes of test specification and execution can be split up into clearly definable blocks.
Example:
The below flowchart is for a program that accepts 3 numbers from the User and prints the highest.
 




Now the Cyclomatic Complexity of the above flowchart is 4 which is the min. number of required test cases.
Looking at the above flowchart the different paths from the above scenario are:
  1. 1,2,4
  2. 1,2,5
  3. 1,3,6
  4. 1,3,7
Now that we have the scenario we can further break down the scenarios to individual test cases using Equivalence and Boundary value analysis and State Transition testing methodologies.
Now applying other techniques on the above scenarios we have the following test cases:
Case 1:
  1. Enter A as the greatest number.
  2. Try to enter a character as the value of A
  3. Enter A as a negative value
  4. Enter A as 5.3 and B as 5.2
  5. Enter A as 5.3 and C as 5.2
  6. Enter all numbers of the same value
  7. Enter a very large value number for A
  8. Enter a very small value number for A like 0.1
  9. Try to enter symbols or garbage characters as value of A
  10. Try to enter the value of A as 0

Conclusion

From the above example we can make out that applying Branch Coverage along with traditional methods of test case design give a very comprehensive and exhaustive suit of test cases which can cover functional as well as non-functional and all other aspects of test case design. Of course the skill of the tester in thinking out the test data also is very crucial for test case designing.

References:

No comments: