Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 10:20 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Topic
 Topic subject: software unit testing
PostPosted: Tue Jun 30, 2009 1:00 am 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2103
Location: Earth
Has thanked: 39 time
Have thanks: 56 time

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).

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Vina Poster - Software for Online Marketing and SEO  Market  biggirl2012  0
 How to protect your software  Java  msi_333  7
 Passcert 920-808 testing materials sharing  General Discussion  Delia  0
 Best Job of Software Developer  General Discussion  brick7  2
 Software Best Practices Training topics required  Java  gangesTech  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Topic | Next Topic 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team