残りのフレームワークでスクリプトを実行しようとすると、エラーが発生します。同じことを解決するために私を案内してください。そして私は以下の瓶を使用しました
Javaバージョン-8 rest-assured-2.8.0 json-path-2.8.0 hamcrest-all-1.3 commons-lang3-3.0 json-schema-validator-2.2.0
失敗:foo Java.lang.NoClassDefFoundError:io/restassured/mapper/factory/GsonObjectMapperFactory at io.restassured.config.RestAssuredConfig。(RestAssuredConfig.Java:41)at io.restassured.RestAssured。(RestAssured.Java:420)が実際.GetRequest.foo(GetRequest.Java:12)at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at Sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at Sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at Java。 lang.refng.Method.invoke(Unknown Source)at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.Java:108)at org.testng.internal.Invoker.invokeMethod(Invoker.Java:661)at org.testng。 internal.Invoker.invokeTestMethod(Invoker.Java:869)at org.testng.internal.Invoker.invokeTestMethods(Invoker.Java:1193)at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.Java:126)at org.testng org.testng.TestRunner.privateRun(TestRunの.internal.TestMethodWorker.run(TestMethodWorker.Java:109) ner.Java:744)org.testng.TestRunner.run(TestRunner.Java:602)at org.testng.SuiteRunner.runTest(SuiteRunner.Java:380)at org.testng.SuiteRunner.runSequentially(SuiteRunner.Java:375 )org.testng.SuiteRunner.privateRun(SuiteRunner.Java:340)at org.testng.SuiteRunner.run(SuiteRunner.Java:289)at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.Java:52)at org.testng .SuiteRunnerWorker.run(SuiteRunnerWorker.Java:86)at org.testng.TestNG.runSuitesSequentially(TestNG.Java:1301)at org.testng.TestNG.runSuitesLocally(TestNG.Java:1226)at org.testng.TestNG.runSuites( TestNG.Java:1144)org.testng.TestNG.run(TestNG.Java:1115)at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.Java:132)at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG .Java:230)at org.testng.remote.RemoteTestNG.main(RemoteTestNG.Java:76)原因:Java.lang.ClassNotFoundException:io.restassured.mapper.factory.GsonObjectMapperFactory at Java.net.URLClassLoader.findClass(Unknownソース)Javaで.lang.ClassLoader.loadClass(Unknown Source)at Sun.misc.Launcher $ AppClassLoader.loadClass(Unknown Source)at Java.lang.ClassLoader.loadClass(Unknown Source)... 28その他
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
これに遭遇した人にとっても、私はこのgitページも参考にした: https://github.com/rest-assured/rest-assured/issues/1168
そして、最終的に動作した私のmaven POMの例はこれです:
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${io-rest-assured.version}</version>
<scope>test</scope>
</dependency>
<!--Added required depeendencies due to : https://github.com/rest-assured/rest-assured/issues/1168 -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-common</artifactId>
<version>${io-rest-assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>${io-rest-assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>${io-rest-assured.version}</version>
</dependency>
エラーを確認する場合、GSONはRest Assuredへのオプションの依存関係であるため、クラスパスまたはPOM依存関係セクションに明示的に配置する必要があります。
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>