我是使用放心和 eclipse 進行 api 自動化測驗的初學者。我收到一個錯誤,我不知道如何解決它。
這是錯誤:
啟動層初始化時出錯 java.lang.module.FindException: Module restAssuredNewProject not found
我也在使用 maven。我的eclipse版本是:版本:2021-06(4.20.0)構建ID:20210612-2011
Java 版本是: 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,混合模式)
這是我的代碼:
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);
}
}
這是 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>
這是模塊資訊.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"...
uj5u.com熱心網友回復:
快速修復是洗掉檔案module-info.java,然后從命令列運行mvn clean test-compile。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/357294.html
標籤:java eclipse maven rest-assured
