Running and testing application
Posted on: February 17, 2011 at 12:00 AM
In this tutorial you will learn how to make a database driven application is struts

Running And Testing Application

The complete database driven application with testing is given below

You can test your application many way like using Mock Object or by using JUnit Framework. I have used Junit to test Action class.

To test you application using JUnit you need to extend the TestCase class of Junit and then write the test case. To know more about the action testing click on the Here.

Here a simple test is done for the execute method of StudenAdmission class. Consider the example

package net.roseindia.test;

import junit.framework.TestCase;
import net.roseindia.action.AdmissionAction;

import com.opensymphony.xwork2.ActionSupport;

public class AdmissionActionTest extends TestCase {

	String result;
	AdmissionAction addmission = new AdmissionAction();

	protected void setUp() throws Exception {
		// TODO Auto-generated method stub

	public void testExecute() {
		try {
			result = addmission.execute();
		} catch (Exception e) {
			System.out.println("Error Message " + e.getMessage());
		assertEquals(ActionSupport.INPUT, result);

	protected void tearDown() throws Exception {
		// TODO Auto-generated method stub

When you run this application it will display message as shown below:


Download Select Source Code

Related Tags for Running and testing application :