পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Saturday, January 21, 2017

JUnit - Plug with Eclipse

To set up JUnit with eclipse, 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 Eclipse Environment

Open eclipse → right click on project and click on property > Build Path > Configure Build Path and add the junit-4.10.jar in the libraries using the button Add External Jar.
Add junit-4.10.jar in liraries. We assume that your Eclipse has inbuilt JUnit plugin. If it is not available in C:\>eclipse\plugins directory, then you can download it from JUnit Plugin. Unzip the downloaded zip file in the plugin folder of the Eclipse. Finally restart Eclipse.
Now your Eclipse is ready for the development of JUnit test cases.

Step 3: Verify JUnit installation in Eclipse

Create a project TestJunit in Eclipse at any location. Then create a class MessageUtil to test in the project.
   
/*
* This class prints the given message on console.
*/

public class MessageUtil {

   private String message;

   //Constructor
   //@param message to be printed
   public MessageUtil(String message){
      this.message = message;
   }
      
   // prints the message
   public 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;

public class TestJunit {
 
   String message = "Hello World"; 
   MessageUtil messageUtil = new MessageUtil(message);

   @Test
   public void testPrintMessage() {   
      assertEquals(message,messageUtil.printMessage());
   }
}
Following should be the project structure −
Project Structure Finally, right click the program and run as JUnit to verify the output of the program.
Run Junit Verify the result.
JUnit result success.

No comments:

Post a Comment