我一直致力于一个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之前成功运行,但我想继续使用这个新版本,因为附加功能对我的项目很有用。可能有一个我不知道的微妙变化,所以任何帮助都会非常感激。
答案 0 :(得分:0)
是的,1.0.3中有一个微妙的变化,特别是在用于运行测试的EvoRunner类中。要进行检测,有两种方法:使用Java代理,使用自定义类加载器。默认情况下是Java Agent,但现在我们使用自定义类加载器(长篇故事......)。
我猜你的一些副作用“我正在创建一个新的类加载器”,如果它与用于加载ES代码的那个不同。
快速检查是在{/ p>中设置为false separateClassLoader
@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)
如果从命令行运行ES,则可以尝试选项-Duse_separate_classloader=false