Total members 11894 |It is currently Sat Nov 23, 2024 4:16 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka






Testing is one of the main phases in software engineering. It includes execution of different scenarios to deliver a bug free and well tested product that ensure high quality to customer.The testing is divided into the following 5 types .

1. Component testing:
Component will be for example a set of tightly related classes. These classes are combined together to achieve a certain functionality.
2. System testing:
Taking into the consideration overall functionality of the system. All the functions of the system are covered.
3. Acceptance testing:

Check if the system achieves the customer functional requirement.

4. Load testing:
Checking the system stability and how it will behave under high load circumstances.

5. Unit testing:
Testing the software using validation methods .The unit is the smallest part of testing in the software.
Unit testing tools : Junit ,Cactus , Junitee ,SOAPUI

a. JUnit test framework

JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java.
JUnit is now the unofficial standard for unit testing Java-based applications. the common structure

Here is a code sample :
Code:
package org.calc.test;
import static org.junit.Assert.*;
import junit.framework.TestCase;
import org.calc.Calculator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class CalculatorTest1 extends TestCase
{
Calculator calc=null;
public void setUp() throws Exception
{
calc=new Calculator();
}
public void tearDown() throws Exception
{
calc=null;
}
public void testAdd()
{
long result=calc.add(3, 4);
assertEquals(7, result);
}
}


Assert methods :
static void assertEquals (boolean expected, boolean actual)
Asserts that two booleans are equal.
static void assertFalse (boolean condition)
Asserts that a condition is false.
static void assertNotNull (java.lang.Object object)
Asserts that an object isn't null.
static void assertNotSame (java.lang.Object expected, java.lang.Object actual)
Asserts that two objects refer to the same object.
static void assertNull (java.lang.Object object)
Asserts that an object is null.
static void assertSame
(java.lang.Object expected, java.lang.Object actual)
Asserts that two objects refer to the same object.
static void assertTrue (boolean condition)
Asserts that a condition is true.
static void fail (java.lang.String message)
Fails a test with the given message.
static void failNotEquals
(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
private static void failNotSame
(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
private static void failNotEquals
(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
private static void failSame (java.lang.String message)
(package private) static java.lang.String format (java.lang.String message, java.lang.Object expected, java.lang.Object actual)
Test suite

A test suite is a composite of related tests that you can run during the same session. There are two convenient ways that JUnit runs test cases:
With the first way, you pass the test class to the TestSuite constructor by using this command:
TestSuite suite= new TestSuite(testAddJava.class) In this case, the TestRunner extracts all test methods that have a test prefix, and then executes each test case automatically.
The alternative way is add each test case by using the TestSuite.addTest method:
Code:
TestSuite suite = new TestSuite(); suite.addTest(new AddJavaTest("testSimpleAddition"));


b. Cactus test Framework
Cactus is a simple test framework for unit testing server-side java code (Servlets, EJBs, Tag Libs, Filters, ...) The intent of Cactus is to lower the cost of writing tests for server-side code. It uses JUnit and extends it.
c. JUnitEE test framework
JUnitEE is a simple extension to JUnit which allows standard test cases to be run from within a J2EE application server. It is composed primarily of a servlet which outputs the test results as html
d. SoapUI
SOAPUI is a is a free and open source desktop application for inspecting, invoking and testing (functional and load) of web services over HTTP. It is mainly aimed at developers/testers providing and/or consuming web services (java, .NET, etc).



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : software unit testing
 unit step and impulse function L.T     -  
 Testing the Type of a Variable     -  
 JUnit Testing of GUIs in Swing     -  
 How to protect your software     -  
 Trainee Software Engineers     -  
 Software Best Practices Training topics required     -  










Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com