#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Core Java

Setting Up System: Eclipse, Java, Maven, Rest-assured and TestNG

What You Need Installed

  • JDK (Java Development Kit): provides the compiler and runtime needed to write and run Java code.
  • Eclipse IDE: the editor used to write, run, and debug Java and Rest Assured projects.
  • Maven: a build tool that manages project dependencies (like Rest Assured and TestNG) automatically.
  • Rest Assured & TestNG: added as Maven dependencies inside the project's pom.xml rather than installed separately.

Basic Setup Steps

Install the JDK and set the JAVA_HOME environment variable, install Eclipse (with the Maven plugin, usually bundled by default), create a new Maven project, and add the Rest Assured and TestNG dependencies to pom.xml.

Why This Foundation Matters

Getting this environment right once means every later exercise — writing Java code, running TestNG tests, or automating APIs with Rest Assured — works smoothly without setup issues getting in the way.

Step-by-Step Installation Check

After installing each piece, confirm it works from a terminal. Catching a problem here saves hours of confusing errors later inside the IDE.

java -version      # should show the JDK you installed
javac -version     # proves it is a full JDK, not only a runtime
mvn -v             # shows Maven version and the Java home it uses
echo %JAVA_HOME%   # Windows; use echo $JAVA_HOME on macOS or Linux

If mvn -v reports a different Java than java -version, fix JAVA_HOME first. On Windows, also add %JAVA_HOME%in and the Maven bin folder to the Path variable, then open a new terminal so the change is picked up. Eclipse ships with its own embedded Maven, so a separate Maven install is mainly needed for running builds from the command line or a CI server.

Creating the Project and pom.xml

  1. In Eclipse, choose File > New > Maven Project, tick "Create a simple project", and give a Group Id such as com.example and an Artifact Id such as api-tests.
  2. Open pom.xml and add the dependencies below. Look up the current versions on Maven Central and place them in the properties section.
  3. Right-click the project and select Maven > Update Project so Eclipse downloads the libraries.
<properties>
  <maven.compiler.release>17</maven.compiler.release>
  <restassured.version>REPLACE_WITH_CURRENT</restassured.version>
  <testng.version>REPLACE_WITH_CURRENT</testng.version>
</properties>

<dependencies>
  <dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>${restassured.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>${testng.version}</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Set maven.compiler.release to the JDK version you actually installed.

Keeping versions in properties means you update them in one place later. Avoid copying very old version numbers from random blog posts; outdated libraries are a common cause of strange errors and security warnings.

A sensible folder layout keeps things tidy as the project grows: page or endpoint helpers under src/test/java/api, test classes under src/test/java/tests, and configuration files such as base URLs under src/test/resources.

Your First Test to Prove the Setup

Create a class under src/test/java. Test code belongs there because the dependencies use the test scope.

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import org.testng.annotations.Test;

public class SmokeTest {
    @Test
    public void getSinglePost() {
        given()
            .baseUri("https://jsonplaceholder.typicode.com")
        .when()
            .get("/posts/1")
        .then()
            .statusCode(200)
            .body("id", equalTo(1));
    }
}

Install the TestNG plugin from the Eclipse Marketplace to get the "Run As > TestNG Test" option, or run mvn test from the project folder.

Problems New Learners Hit

  • "No compiler is provided": Eclipse points to a JRE. Add the JDK under Window > Preferences > Java > Installed JREs.
  • Red imports for Rest Assured: the test class sits in src/main/java, where test-scoped libraries are not visible.
  • Dependencies not downloading: a company proxy blocks Maven; configure it in settings.xml.
  • Static import errors: given() and matchers need the static imports shown above.
  • TestNG tests not found by mvn test: class names should end with Test, or you should point the Surefire plugin at a testng.xml file.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course