运行java程序时收到以下消息。我看到很多建议要删除JUNIT并尝试哪个工作完全正常但同时影响我的RunnerClass(下面)。在其他帖子中给出了一些建议,但显然似乎没有一个在我的案例中起作用。任何帮助将非常感谢。
RunnerClass: -
package HybridFrameWork;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features="src\\test\\java\\HybridFrameWork", glue={"HybridFrameWork"},plugin="html:reports")
public class RunnerFile {
}
我的Java程序是: -
package ServiceTesting;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import org.testng.annotations.Test;
import HybridFrameWork.Variables;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;
import io.restassured.specification.RequestSpecification;
import ServiceTesting.Authentication;
public class Forgotpassword {
@Test(priority=1)
@Given("^Headers in Json format along with valid token$")
public static void Headers_in_Json_format_along_with_valid_token() throws Throwable {
Authentication.userlogin();
RequestSpecification Request=given().header("Authorization", "bearer "+Variables.getToken()).contentType(ContentType.JSON);
Variables.setRequest(Request);
}
@Test(priority=2)
@When("^Approprite email address in request body$")
public static void Approprite_email_address_in_request_body() throws Throwable {
RequestSpecification Request=Variables.getRequest().when().body("{\"Email\":\"XXY@YZZ\"}");
Variables.setRequest(Request);
}
@Test(priority=3)
@And("^Trigger the valid end point of forgot password$")
public static void Trigger_the_valid_end_point_of_forgot_password() throws Throwable {
Response Response=(Response) Variables.getRequest().post("XX//YY//ZZ");
Variables.setResponse(Response);
}
@Test(priority=4)
@Then("^Validation of all the response details$")
public static void Validation_of_all_the_response_details() throws Throwable {
ValidatableResponse Response=Variables.getResponse().then().statusCode(200).content("message", equalTo("XXYYZZ"));
}
}
错误讯息: -
java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668)
at java.lang.ClassLoader.defineClass(ClassLoader.java:761)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:128)
at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:117)
at ServiceTesting.Authentication.userlogin(Authentication.java:36)
at ServiceTesting.Forgotpassword.Headers_in_Json_format_along_with_valid_token(Forgotpassword.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:669)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:877)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1201)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:776)
at org.testng.TestRunner.run(TestRunner.java:634)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:425)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:420)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:385)
at org.testng.SuiteRunner.run(SuiteRunner.java:334)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1318)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1243)
at org.testng.TestNG.runSuites(TestNG.java:1161)
at org.testng.TestNG.run(TestNG.java:1129)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)