Wednesday, August 10, 2011

Simple Tutorial on JUNIT Configuration with Eclipse- Helios

Simple Tutorial on JUNIT Configuration with Eclipse- Helios
---------------------------------------------------------------
1. Copy the Junit.jar from the shared folder of IP 10.254.222.116/downloads to eclipse plugin folder
2. Next Right click on the eclipse Project and click on properties



3. Below Screen will pop up



4. Click on the Add library button on right side , below screen will come



5. Check the User Library and say next



6. Click on the User Libraries





7. Click on New and enter the library name.



8. Enter the library name and click on Ok button



9. Click on the name u entered and click on Add jar from the jar file u copied from eclipse plugin and say open. This creates the library .



10. After creating the user defined libraries right click the project and Say Add user libraries and say finish.



11. Now the Junit capabilities are added to the project

Create a separate package for Junit test case and create as per the below screen



Click on Next
Give the Source Folder
Package
Name
Class which you want to test by browse





Say Ok and click on finish

Your Unit test class should be --- SAMPLE CODE ---

/** */
package com.emc.slaa.ws.junit;
import static org.junit.Assert.*;
import org.junit.Test;
import com.emc.slaa.ws.HelloWorldService;

/**
* @author arun paria
*/
public class HelloWorldUnitTest {
/**
* Test method for {@link com.emc.slaa.ws.HelloWorldService#sayHelloWorld(java.lang.String)}.
*/
@Test
public void testSayHelloWorld() {

HelloWorldService hservice= new HelloWorldService();
//assertEquals("Hello World Server:Response Succee",hservice.sayHelloWorld("Hello World"));
System.out.println("JUnit o/p:"+hservice.sayHelloWorld("Hello World"));
//fail("Not yet implemented");

}
}

12. FINAL Out Put
You should get the Green color for the success .
If the unit test case is fail you will get as red.




No comments:

Post a Comment