You are on page 1of 8

Testing:

You have been writing code but it is very important to deliver a bug free code.
Testing is the process of checking the functionality of an application to ensure that it runs
as per requirements and does not have a bug.

The process of identifying and removing bugs or errors from a computer program is
known as debugging. Debugging can be done manually or by using different tools.
Consider the below findSum method which calculates the sum of the first n natural numbers.
public int findSum(int n) {
int sum = 0;
for (int i = 1; i <= n; i++) {
sum = sum + i;
}
return sum;
}
The code runs without an error but the output is not as expected. We need to find out the
error or bug in our code. This is simple if we have a single method but imagine an entire
application where different methods are dependent on one another. In such a case, it becomes
very difficult to find out where the bug is present. 
So, we need the help of tools for debugging.
Eclipse provides different tools for debugging. Using these tools, we can run the program
interactively and watch the code during each step of the execution. This makes it easier to
identify the point at which the error was made.
Test types
Software test can be classified in many ways
Based on requirements

Functional testing:
Testing the application against business requirements. Functional testing is done using the
functional specifications provided by the client or by the design specification provided by design
team.

Based on testing method (Box approach)

1. White box testing


2. Black box testing
3. Grey box testing

Based on Test target

1. Unit test
2. Integration test
3. System test
4. System integration test
5. Incremental integration test

Based on objective 

1. Regression test
2. Alpha test
3. Beta test
4. Sanity test
5. Smoke test
6. Interface and Usability test
7. User Acceptance Test
8. Globalization
9. Localization

Non-Functional testing:

Testing the application against client's and performance requirement. Non-Functional testing
is done based on the requirements and test scenarios defined by the client.

 Load and Performance Testing


 Ergonomics Testing
 Stress & Volume Testing
 Compatibility & Migration Testing
 Data Conversion Testing
 Security / Penetration Testing
 Operational Readiness Testing
 Installation Testing
 Security Testing (Application Security, Network Security, System Security)

The box approach


Software testing methods are traditionally divided into white- and black-box testing.
These two approaches are used to describe the point of view that a test engineer takes when
designing test cases
White box testing
White box testing is when the tester has access to the internal data structures and
algorithms including the code that implement these.
Example: Path Coverage, Logic Coverage, Statement Coverage
Black box testing
Black box testing treats the software as a "black box"—without any knowledge of
internal implementation. 
Example: Boundary Value Analysis
Grey Box Testing
Grey box testing is a software testing technique to test a software product or application
with partial knowledge of internal structure of the application. The purpose of grey box testing is
to search and identify the defects due to improper code structure or improper use of applications.
Gray Box Testing is a software testing method, which is a combination of both White Box
Testing and Black Box Testing method.
 In White Box testing internal structure (code) is known
 In Black Box testing internal structure (code) is unknown
 In Grey Box Testing internal structure (code) is partially known
Statement Coverage:
In this the test case is executed in such a way that every statement of the code is executed
at least once.
Branch/Decision Coverage:
Test coverage criteria requires enough test cases such that each condition in a
decision takes on all possible outcomes at least once, and each point of entry to a program
or subroutine is invoked at least once.  That is, every branch (decision) taken each way, true and
false. It helps in validating all the branches in the code making sure that no branch leads to
abnormal behavior of the application. 
Path Coverage:
In this the test case is executed in such a way that every path is executed at least
once. Path testing is a structural testing method that involves using the source code of a program
in order to find every possible executable path. It helps to determine all faults lying within a
piece of code. This method is designed to execute all or selected path through a computer
program.
All possible control paths taken, including all loop paths taken zero, once, and
multiple (ideally, maximum) items in path coverage technique, the test cases are prepared
based on the logical complexity measure of a procedural design. In this type of testing
every statement in the program is guaranteed to be executed at least one time.

In the above example, we can see there are few conditional statements that are executed
depending on what condition it suffice. Here there are 3 paths or condition that needs to be tested
to get the output,
 Path 1: 1,2,3,5,6, 7
 Path 2: 1,2,4,5,6, 7
 Path 3: 1, 6, 7
Boundary Value Analysis
Boundary Value Analysis (BVA) is a Black-Box testing technique used to check the
errors at the boundaries of an input domain. 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 name comes from the Boundary, which means the limits of an area. So, BVA mainly
focuses on testing both valid and invalid input parameters for a given range of a software
component.
If (Min,MAX) is the range given for a field validation, then the boundary values come as
follows:
Invalid Boundary Check   { Min-1 ; Max+1 }   
Valid Boundary Check   {Min; Min+1 ;Max-1;Max }    
The software system will be passed in the test if it accepts a valid number and gives the
desired output, if it is not, then it is unsuccessful. In another scenario, the software system should
not accept invalid numbers, and if the entered number is invalid, then it should display error
massage.
Example of Boundary Value Analysis :
Requirement: Validate AGE field, which accepts values from 21-60.
We verify the following Boundary Value Test cases:
TC001: Validate AGE by entering  20 [ Min-1]: Invalid Boundary Check
TC002: Validate AGE by entering  21 [ Min]: Valid Boundary Check
TC003: Validate AGE by entering  22 [ Min+1]: Valid Boundary Check
TC004: Validate AGE by entering  59 [ Max-1]: Valid Boundary Check
TC005: Validate AGE by entering  60 [ Max]: Valid Boundary Check
TC006: Validate AGE by entering  61[ Max+1]: Invalid Boundary Check
The main advantage of Boundary Value Analysis is that the testing time is less as the tester will
analyze the data only at the boundaries.
Example:
Consider the below code written by Peter. He wants to test his code using Logic Coverage
technique. Suggest him the most efficient test data set
motorcycle_type="Bike"
years_old=6
if motorcycle_type=="Bike":
if years_old>=5 and years_old<=10:
mileage=45
elif years_old>=11:
mileage=40
else:
mileage=25
elif motorcycle_type=="Scooter":
mileage=35
else:
mileage=20
1) motorcycle_type: “Bike” with years_old(4,8,-1) “Scooter” “Bus”
2) motorcycle_type: “Bike” “Scooter” “Bus”
3) motorcycle_type: “Bike” with years_old(6,9,100) “Scooter” “Bus”
4) motorcycle_type: “Bike” with years_old(2,7,15) “Scooter” “Bus”

Consider the below code snippet. Identify the most efficient test data set for testing the below
code using "Logic Coverage' technique.
if previous_year_percentage>=75 and previous_year_percentage<=85:
scholarship=5000
elif previous_year_percentage>=85 and previous_year_percentage<=95:
scholarship=8000
elif previous_year_percentage>=95
scholarship=10000
else:
scholarship=0
1. 79,87,91,99
2. 78,80,92,99
3. 74,77,90,100
4. 74,75,76,84,85,86,94,95,96,97
Assume we have to test a text field (Name) which accepts the length between 6-12 characters.

Minimum boundary value is 6

Maximum boundary value is 12

Valid text length is 6, 7, 11, 12

Invalid text length is 5, 13

Test case 1: Text length of 5 (min-1) = Invalid

Test case 2: Text length of exactly 6 (min) = Valid

Test case 3: Text length of 7 (min+1) = Valid

Test case 4: Text length of 11 (max-1) = Valid

Test case 5: Text length of exactly 12 (max) = Valid

Test case 6: Text length of 13 (max+1) = Invalid

Which of the following hash function would lead to the least number of collisions when the
following values are stored,
48,98,34,25,18
1) H(key)=key%9 3,8,7,7,0
2) H(key)=key%10 8,8,4,5,8
3) H(key)=key%8 0,2,2,1,2
4) H(key)=key%3 0,2,1,1,0
Following elements are to be stored in hash table using the hash function h(k)=k%8 in the order
shown:
65,27,50,9,36,43,20
Identify the hash values for which collision occurs.

A) Collision will occur for hash values 1,2


B) No collision will occur
C) Collision will occur for hash values 1,4
D) Collision will occur for hash values 1,3,4

You might also like