我试图用maven和tesng运行一个API测试,在执行过程中,一些错误出现在consol上,我使用intellij,java 8,testng和maven任何想法如何解决这个问题
错误:
Apr 27, 2020 1:03:58 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: org/codehaus/groovy/runtime/callsite/AbstractCallSite
java.lang.RuntimeException: bad non-abstract method with no code: void org.codehaus.groovy.runtime.callsite.AbstractCallSite.<init>(org.codehaus.groovy.runtime.callsite.CallSiteArray, int, java.lang.String) on public class org.codehaus.groovy.runtime.callsite.AbstractCallSite
at org.aspectj.weaver.bcel.LazyMethodGen.<init>(LazyMethodGen.java:223)
at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:362)
at org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen(BcelObjectType.java:563)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1706)
at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1657)
at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1422)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1196)
at org.aspectj.weaver.tools.WeavingAdaptor.getWovenBytes(WeavingAdaptor.java:551)
at org.aspectj.weaver.tools.WeavingAdaptor.weaveClass(WeavingAdaptor.java:387)
at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:116)
at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(ClassPreProcessorAgentAdapter.java:51)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
at org.codehaus.groovy.reflection.SunClassLoader.define(SunClassLoader.java:94)
at org.codehaus.groovy.runtime.callsite.GroovySunClassLoader.loadAbstract(GroovySunClassLoader.java:72)
at org.codehaus.groovy.runtime.callsite.GroovySunClassLoader.<init>(GroovySunClassLoader.java:54)
at org.codehaus.groovy.runtime.callsite.GroovySunClassLoader.<init>(GroovySunClassLoader.java:49)
at org.codehaus.groovy.runtime.callsite.GroovySunClassLoader.lambda$static$0(GroovySunClassLoader.java:40)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.GroovySunClassLoader.<clinit>(GroovySunClassLoader.java:37)
at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.isCompilable(CallSiteGenerator.java:256)
at org.codehaus.groovy.reflection.CachedMethod.createStaticMetaMethodSite(CachedMethod.java:312)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.createStaticMetaMethodSite(StaticMetaMethodSite.java:112)
at groovy.lang.MetaClassImpl.createStaticSite(MetaClassImpl.java:3496)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:74)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:156)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
at io.restassured.internal.common.assertion.AssertParameter.notNull(AssertParameter.groovy:21)
at io.restassured.config.SSLConfig.<init>(SSLConfig.java:192)
at io.restassured.config.SSLConfig.<init>(SSLConfig.java:184)
at io.restassured.config.RestAssuredConfig.<init>(RestAssuredConfig.java:41)
at io.restassured.RestAssured.<clinit>(RestAssured.java:421)
at Tests.Android.API.getUserDetailsTest(API.java:15)
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:134)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:597)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
测试:这是我使用testng执行的一个示例测试
public class API {
@Test(priority = 1)
public void getUserDetailsTest() {
RestAssured.baseURI = "https://test.com";
RequestSpecification httpRequest = RestAssured.given();
Response response = httpRequest.request(Method.GET,"/");
String responseBody=response.getBody().asString();
int statusCode=response.getStatusCode();
System.out.println("Status code is: "+statusCode);
Assert.assertEquals(statusCode, 200);
}
}
POM:这是我的POM xml文件和所有使用的依赖项的示例
<properties>
<jre.level>1.8</jre.level>
<jdk.level>1.8</jdk.level>
<aspectj.version>1.9.5</aspectj.version>
</properties>
<build>
<plugins>
<!-- Compiler plug-in -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${jdk.level}</source>
<target>${jdk.level}</target>
</configuration>
</plugin>
<!-- Added Surefire Plugin configuration to execute tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<suiteXmlFiles>
<suiteXmlFile>src/test/java/Suites/TestNG.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
</dependency>
<!-- <!– https://mvnrepository.com/artifact/io.qameta.allure/allure-testng –>-->
<!--https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server-->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<!-- log4j2 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
通过升级到JDK11解决了问题
可以尝试添加groovy依赖项吗
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>3.0.3</version>
</dependency>
我得到了同样的错误,当我使用重新保证4.3.0。我已经将其更改为4.2.0,并且不再显示此错误。
我有一个应用程序(使用注释的Spring 4 MVC Hibernate 4 MySQL Maven集成示例),使用基于注释的配置将Spring与Hibernate集成,但运行测试时出错! 上课时间到了 下面是即将到来的考验: 这是pom。xml文件:
我想并行运行Junit测试。我遇到了以下问题 这些测试是由其他团队开发的,大约有2500个测试套件。测试和测试框架到处都有静态变量。它们的编写使得它们在一次运行一个套件时可以正常工作。当我构建一组这些测试套件并运行它们时,它们甚至没有完成运行。 为了解决这个问题,我有自己的测试运行程序,它通过不同的类加载器(一次一组测试)加载测试套件。我在多个线程中这样做,并从每个线程调用JunitCore的ru
问题内容: 我正在使用mocha-phantomjs设置进行单元测试。我有以下package.json脚本来运行测试。 在浏览器中可以正常运行。当我在cmd中运行命令时,测试运行正常,但同时也会出现以下错误 请任何人告诉我如何解决此错误。 问题答案: 当我在cmd中运行命令npm test时,测试运行正常 不,他们不是。您有6个失败的测试。的退出代码等于测试失败的次数。直接运行,看看有什么问题。意
我试图用JUnit5控制台启动器运行一个简单的测试。我试了几个选择,但都不起作用。谁能告诉我哪里出了问题吗? .+--JUnit Jupiter[OK] '--JUnit Vintage[OK] 测试运行在11毫秒后完成[2个容器] [0个容器跳过][2个容器启动] [0个容器中止][2个容器成功] [0个容器失败][0个测试找到] [0个测试跳过][0个测试启动] [0个测试中止][0个测试成功
问题内容: 我正在尝试使用JUnit5控制台启动器运行一个简单的测试。我尝试了几种选择,但是没有用。有人可以告诉我哪里出了问题吗? 给我警告 我试图在目录中运行所有测试,但这似乎找不到测试: 结果是这样的: 。+-JUnit Jupiter [确定] ‘-JUnit Vintage [确定] 11毫秒后测试运行完成[找到2个容器] [跳过0个容器] [0个容器中止] [2个容器成功] [0个容器失