- JUnit - Extensions
- JUnit - Plug with Eclipse
- JUnit - Plug with Ant
- JUnit - Parameterized Test
- JUnit - Exceptions Test
- JUnit - Time Test
- JUnit - Ignore Test
- JUnit - Suite Test
- JUnit - Executing Tests
- JUnit - Execution Procedure
- JUnit - Using Assertion
- JUnit - Writing a Tests
- JUnit - API
- JUnit - Basic Usage
- JUnit - Test Framework
- JUnit - Environment Setup
- JUnit - Overview
- JUnit - Home
JUnit Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JUnit - Plug with Ecppse
To set up JUnit with ecppse, follow the steps given below.
Step 1: Download JUnit Archive
Download a JUnit jar based on the operating system you have on your system.
OS | Archive Name |
---|---|
Windows | junit4.10.jar |
Linux | junit4.10.jar |
Mac | junit4.10.jar |
Assume you have copied the above JAR file onto the folder C:>JUnit.
Step 2: Set Ecppse Environment
Open ecppse → right cpck on project and cpck on property > Build Path > Configure Build Path and add the junit-4.10.jar in the pbraries using the button Add External Jar.
We assume that your Ecppse has inbuilt JUnit plugin. If it is not available in C:>ecppseplugins directory, then you can download it from JUnit Plugin. Unzip the downloaded zip file in the plugin folder of the Ecppse. Finally restart Ecppse.
Now your Ecppse is ready for the development of JUnit test cases.
Step 3: Verify JUnit installation in Ecppse
Create a project TestJunit in Ecppse at any location. Then create a class MessageUtil to test in the project.
/* * This class prints the given message on console. */ pubpc class MessageUtil { private String message; //Constructor //@param message to be printed pubpc MessageUtil(String message){ this.message = message; } // prints the message pubpc String printMessage(){ System.out.println(message); return message; } }
Create a test class TestJunit in the project.
import org.junit.Test; import static org.junit.Assert.assertEquals; pubpc class TestJunit { String message = "Hello World"; MessageUtil messageUtil = new MessageUtil(message); @Test pubpc void testPrintMessage() { assertEquals(message,messageUtil.printMessage()); } }
Following should be the project structure −
Finally, right cpck the program and run as JUnit to verify the output of the program.
Verify the result.
Advertisements