Sunday, 24 June 2018

Junit: Setting up junit project in eclipse

In this post, I am going to explain how to setup simple junit maven project in eclipse.

Step 1: Open Eclipse
File -> New -> Maven project

Select the checkbox ‘Create a simple project (skip archetype selection)’


Click on Next button.


Give Group Id, Artifact Id as junitDemo, version as 1 and click on Finish button.

Project structure looks like below.


Open pom.xml and add maven dependency.

                  <!-- https://mvnrepository.com/artifact/junit/junit -->
                  <dependency>
                           <groupId>junit</groupId>
                           <artifactId>junit</artifactId>
                           <version>4.12</version>
                           <scope>test</scope>
                  </dependency>

Final pom.xml file looks like below.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>junitDemo</groupId>
 <artifactId>junitDemo</artifactId>
 <version>1</version>

 <dependencies>
  <!-- https://mvnrepository.com/artifact/junit/junit -->
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.12</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
</project>



Previous                                                 Next                                                 Home

No comments:

Post a Comment