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.ADS_TO_REPLACE_1
Here a simple test is done for the execute method of StudenAdmission class. Consider the example
AdmissionActionTest.java
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(); @Override protected void setUp() throws Exception { // TODO Auto-generated method stub super.setUp(); } public void testExecute() { try { result = addmission.execute(); } catch (Exception e) { System.out.println("Error Message " + e.getMessage()); } assertEquals(ActionSupport.INPUT, result); } @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub super.tearDown(); } }
Download Select Source CodeADS_TO_REPLACE_2
Advertisements
Ads
Ads