Monday, December 17, 2012

Principles of Testing - Software Testing Principles

Testing is a process to expose hidden defects. It is detecting errors and deviations from specification. It is verifying that a system satisfies its specified requirements or not. Here discuss principles of testing.

Software Testing Principles

Seven General principles of Software testing

Principle 1. Exhaustive Input Testing
Exhaustive input testing means test all possible input condition as test cases. Test for all valid and invalid input conditions. But it is impossible to test a system for all input test cases.

Principle 2. Testing is creative and difficult
Second principle of testing is "testing is creative and difficult". Yes it requires creativity. It requires extensive domain knowledge. It also requires good testing methodology.

Principle 3. Prevention of defects
It is a procedure to fixing errors. If we find defects in early stages of development then its cost of fixing is less. Cost of fixing of any defect is too higher in later stages. So it's better to go with preventive approach.

Principle 4. Testing is risk based
Testing is risk based process. A risk is a loss associated with an event. Risk can be economical.
Suppose I try to test one module of system. I got some defects. I solved defects but due to modification some more defects appear in same module or other modules. So it is risky process. Sometime it increases the cost of testing.

Principle 5. Testing must be planned
Test planning is essential. Test Planning helps to solve many problems in system. Test plan covers points like requirement of testing, test priority, cost of testing, test team, test strategy, test tools etc. These factors effect on testing.

Principle 6. Testing requires independence
Testing must be unbiased. Unbiased testing is essential to objectively test quality of software. If testing is done by same developer who develop it then it may be biased. Developer can be an emotional attachment with its development. Developer who has to test his or her program parts will tend to be too optimistic. Chances of “blindness to their own errors”. So require to testing done by other than developer to make unbiased.

Principle 7. Provide expected results
It is important principle of testing. Test is done to check system is fulfilling user requirement or not. System must provide expected results. Testing checks that system pre defined specifications achieved or not.

 

Tuesday, May 8, 2012

String Reverse Example in Java Programming

It is a sample string reverse example. In this program read array of string from user and give output array of reverse string.
Here use StringBuffer class and create object name[] of StringBuffer class. Use method reverse() to reverse inserted string.

Program Code

//developed by Om Prakash
import java.util.*;
class StringReverse
{
public static void main(String argv[])
{
int size;
Scanner console=new Scanner(System.in);
System.out.println("*******STRING REVERSE*******");
System.out.print("How many string do you want to enter : ");
size=console.nextInt();
StringBuffer name[]=new StringBuffer[size+1];
String temp;
int i;
System.out.println("Enter "+size+" string : ");
for(i=0;i<=size;i++)
{
temp=console.nextLine();
name[i]=new StringBuffer(temp);
}
System.out.println("String after Reverse");
for(i=0;i<=size;i++)
{
name[i].reverse();
System.out.println(name[i]);
}
}
}

Output





Monday, May 7, 2012

Java AWT vs SWING

Difference between Java AWT and SWING
1. AWT(Abstract Window Toolkit) is a heavy weight but Swing is a light weight.

2. Swing feel and look better than AWT components.

3. Swing is a pure java components but AWT native components.

4. AWT not have complex components but Swing has additional components like JTable, JProgressBar, JSlider, JTree etc.

5. Applet list has scrollbar but Swing JList does not support scrolling but this can be done using scrollPane.

6. Applet not support MDI(multiple document interface) window but Swing support MDI.

7. Applet default layout is FlowLayout but Swing default layout is BorderLayout.

8. AWT menu item cannot have images or radio buttons or checkboxes but Swing menu item can have images or radio buttons or checkboxes.

9. AWT do not have JMV(Java Model Viewport) but All swing components have JMV.

10. In AWT, components can be added directly on the Frame or window but in Swing while adding components on Frame or window, they have to be added on its content pane.

11. Swing has more powerful and flexible components than AWT.


Applets vs Applications - How Applets Differ From Applications


Java Applets and Java applications have many similarities but there are some differences between applets and applications.
1. Applets not use main() method but applications have main() method.

2. Applets execute in web browser or it embedded with web browser but java applications execute normally.

3. Applets are small programs to do specific task but applications are large programs.

4. Applets must extends java.applet.Applet class but java applications start execution with main() method.

5. Applets can not use libraries from other languages such as C or C++ but applications supports this by native methods.

6. Applet can not run independently. It run in webpage but application runs independently.

7. Applets not able to read or write files from local computer but applications can do such task.

8. Applets can not communicate with other servers on the network.

9. Applets have a life cycle with init(), start(), stop(), paint(), destroy() methods but applications not have such methods.