Evosuite 1.0.3 类 'TestClass_ESTest.class' 应该在目标项目中,但找不到



我一直在开发一个 Web 应用程序,该应用程序根据上传的 Java 文件生成测试,并根据所述生成的测试测试上传的代码。我一直在使用 Evosuite 生成测试,没有问题。但是,我刚刚更新到最新版本(1.0.3),现在在运行生成的测试时出现以下错误:

initializationError(PackOfCrisps_ESTest)
java.lang.ClassNotFoundException: Class 'PackOfCrisps_ESTest.class' should be in target project, but could not be found!
at org.evosuite.runtime.instrumentation.EvoClassLoader.instrumentClass(EvoClassLoader.java:125)
at org.evosuite.runtime.instrumentation.EvoClassLoader.loadClass(EvoClassLoader.java:91)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.evosuite.runtime.EvoRunner.getFromEvoSuiteClassloader(EvoRunner.java:139)
at org.evosuite.runtime.EvoRunner.getClass(EvoRunner.java:92)
at org.evosuite.runtime.EvoRunner.<init>(EvoRunner.java:72)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runner.Computer.getRunner(Computer.java:40)
at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87)
at org.junit.runners.Suite.<init>(Suite.java:81)
at org.junit.runner.Computer.getSuite(Computer.java:28)
at org.junit.runner.Request.classes(Request.java:75)
at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:62)
at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:49)
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:497)
at finalYearProject.assignmentManager.util.Marker.setupEnvironment(Marker.java:142)
at finalYearProject.assignmentManager.util.Marker.runTests(Marker.java:353)
at finalYearProject.assignmentManager.util.Marker.<init>(Marker.java:39)
at finalYearProject.assignmentManager.Submissions.doPost(Submissions.java:150)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

为了运行测试,我正在创建一个新的类加载器,其中包含要测试的文件以及从 Evosuite 生成的测试放置的目录的 URL。

在更新 Evosuite 之前,我的应用程序运行成功,但我想继续使用此新版本,因为附加功能对我的项目很有用。可能有一个我不知道的微妙变化,所以任何帮助将不胜感激。

是的,1.0.3中有一个微妙的变化,特别是在用于运行测试的EvoRunner类中。要执行检测,有 2 种方法:使用 Java 代理和自定义类装入器。以前默认是 Java Agent,但现在我们使用自定义类加载器(长话短说......

我想你的"我正在创建一个新的类加载器"有一些副作用,如果这与用于加载 ES 代码本身的那个不同。

快速检查是在以下位置设置为假separateClassLoader

@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)

如果从命令行运行 ES,则可以尝试该选项-Duse_separate_classloader=false

相关内容

  • 没有找到相关文章

最新更新