Friday, February 25, 2011

Software Testing Defect Density


What are various ways of calculating defect density?
The formula itself is simple: Density = Total Defects Found / Size

if we see defect density at granular level say Codesize of a particular functionality X in a application Y along with number of files, then we may draw some good observations like
Taking an example here:- Lets say we have an application ABC, which have three functionality/modules A, B and C. 
Code files for A =10 and KLOC=5k 
Code files for B =5 and KLOC=1k 
Code files for C =1 and KLOC=25k 
Bugs found in A=40, B=50, and C=5

Defect density = Total number of defects/LOC (lines of code)

Defect density = Total number of defects/Size of the project

Size of Project can be Function points, feature points, use cases, KLOC etc
Defect Density can be used to:
1) Predict the remaining defects when compared to the expected defect density,
2) Determine if the amount of testing is sufficient.
3) Establish a database of standard defect densities.

What are you going to do with the defect density information you collect? 
Depending on what you want / expect to discover, you could pilot some different measurements on different parts of the code base and see which versions of the metric were most measurable

Branch Testing | Condition Testing | Data Definition


Branch Testing  
In branch testing, test cases are designed to exercise control flow branches or decision points in a unit. This is usually aimed at achieving a target level of Decision Coverage. Branch Coverage, need to test both branches of IF and ELSE. All branches and compound conditions (e.g. loops and array handling) within the branch should be exercised at least once.
Branch coverage (sometimes called Decision Coverage) measures which possible branches in flow control structures are followed. Clover does this by recording if the Boolean expression in the control structure evaluated to both true and false during execution.

Branch testing comes under white box testing or black box testing? 
Branch testing is done while doing white box testing, where focus is given on code.There are many other white box technique. Like Loop testing.
Condition Testing
The object of condition testing is to design test cases to show that the individual components of logical conditions and combinations of the individual components are correct. Test cases are designed to test the individual elements of logical expressions, both within branch conditions and within other expressions in a unit.
Condition testing is a test case design approach that exercises the logical conditions contained in a program module. A simple condition is a Boolean variable or a relational expression, possibly with one NOT operator. A relational expression takes the form:
E1 <>E 2
where are arithmetic expressions and relational operator is one of the following <, =, , (nonequality) >, or . A compound condition is made up of two or more simple conditions, Boolean operators, and parentheses. We assume that Boolean operators allowed in a compound condition include OR, AND and NOT.
The condition testing method concentrates on testing each condition in a program. The purpose of condition testing is to determine not only errors in the conditions of a program but also other errors in the program. A number of condition testing approaches have been identified. Branch testing is the most basic. For a compound condition, C, the true and false branches of C and each simple condition in C must be executed at least once.
Domain testing needs three and four tests to be produced for a relational expression. For a relational expression of the form:
E1 <>E 2

Three tests are required the make the value of greater than, equal to and less than , respectively.
Data Definition – Use Testing  
Data definition-use testing designs test cases to test pairs of data definitions and uses. Data definition is anywhere that the value of a data item is set. Data use is anywhere that a data item is read or used. The objective is to create test cases that will drive execution through paths between specific definitions and uses.