Home > OS >  How can I resolve this error. Using rest assured & eclipse :Error occurred during initialization of
How can I resolve this error. Using rest assured & eclipse :Error occurred during initialization of

Time:11-12

I am a beginner at using rest assured and eclipse for api automation testing. I am getting an error and I don't know how to resolve it.

Here is the error:

Error occurred during initialization of boot layer java.lang.module.FindException: Module restAssuredNewProject not found

I am using maven too. The eclipse version I have is: Version: 2021-06 (4.20.0) Build id: 20210612-2011

Java version is: C:\Users\rally>java -version java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Here is my code:

import static io.restassured.RestAssured.*;
import io.restassured.RestAssured;
public class Basics {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //Validate if Add Place api is working properly
        //given-all input details
        //when-Submit the api(resource , http methods)
        //Then-Validate the response
        RestAssured.baseURI= "https://rahulshettyacademy.com";
        given().log().all().queryParam("key", "qaclick123").header("Content-type","application/json")
        .body("{\r\n"
                  "  \"location\": {\r\n"
                  "    \"lat\": -38.383494,\r\n"
                  "    \"lng\": 33.427362\r\n"
                  "  },\r\n"
                  "  \"accuracy\": 50,\r\n"
                  "  \"name\": \"Frontline house\",\r\n"
                  "  \"phone_number\": \"( 91) 983 893 3937\",\r\n"
                  "  \"address\": \"29, side layout, cohen 09\",\r\n"
                  "  \"types\": [\r\n"
                  "    \"shoe park\",\r\n"
                  "    \"shop\"\r\n"
                  "  ],\r\n"
                  "  \"website\": \"http://google.com\",\r\n"
                  "  \"language\": \"French-IN\"\r\n"
                  "}\r\n"
                  "").when().post("maps/api/place/add/json")
        .then().log().all().assertThat().statusCode(200);

    }

}

and here is the 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>RestAssuredNewProject</groupId>
  <artifactId>RestAssuredNewProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <release>16</release>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.4.0</version>
   </dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.4.0</version>
    </dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>1.3</version>
    </dependency>
</dependencies>
</project>

This is the module-info.java:

module restAssuredNewProject {
    requires rest.assured;
    requires hamcrest.library;
    requires org.hamcrest;
}

there are a couple of errors here too: One is "Name of automatic module rest.assured is unstable.It is derived from the module's filename." Second error "hamcrest library cannot be resolved to a module"...

CodePudding user response:

Quick fix is delete file module-info.java, then run mvn clean test-compile from command line.

  • Related