我尝试从命令行使用evosuite独立jar生成测试。
我的项目目录在src/czytacz中有源代码,在项目目录中有antlr-4.3-complete.jar
这就是我要做的:将evosuite jar复制到项目目录。
使用命令为项目设置evosuite:
java-jar evosuite-0.1.1.jar-setup src/czytacz antlr-4.3-complete.jar
使用命令创建测试:
java-jar evosuite-0.1.1.jar-target src/czytacz
evosuite:的输出
- EvoSuite
- 在目标src/czytacz中找到0个匹配的类
- 分析类路径(生成继承树)
- antlr-4.2-complete.jar
- src/czytacz
没有为我的项目创建任何测试
-------------------------------编辑------------------------------
谢谢arcuri82它解决了我的问题,但我还有另一个问题。
用于:
krzysiek@krzysiek-Latitude-D630:~/git$sudojava-jarevosuitte-0.1.1.jar-项目CP/home/krzysiek/workspace/czytacz-目标/home/krzysiek/workspace/czytacz/bin/czytacz
我得到:
- EvoSuite
- 在target/home/krzysiek/workspace/czytacz/bin/czytacz中找到6个匹配的类
- 分析类路径(生成继承树)
- /home/krzysiek/workspace/czytacz
- /home/krzysiek/workspace/czytacz/bin/czytacz
- 当前类:Run
- 要为类生成测试用例:Run
- 正在启动客户端
- 连接到端口9969上的主进程
- 正在分析类路径:
- 从/tmp/ES_inheritancetree222898081092137439.xml.gz加载的继承树
- 初始化目标类时出错:在继承树[MASTER]12:37:11.978[pool-1-thread-2]中找不到目标类ErrorTestSuiteGenerator-运行问题。完整堆栈:java.lang.ClassNotFoundException:在中找不到目标类位于的继承树org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:85)~[evosuite--0.1.1.jar:na]在org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)~[evosuite--0.1.1.jar:na]在org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)[evosuite--0.1.1.jar:na]java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)[na:1.8.0_45]java.util.concurrent.FFutureTask.run(FutureTask.java:266)[na:1.8.0_45]在java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)[na:1.8.0_45]java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)[na:1.8.0_45]
- 计算完成[MASTER]12:37:12.272[main]错误SearchStatistics-由于EvoSuite,未保存任何统计信息未能生成任何测试用例[MASTER]12:37:12.374[main]错误TestGeneration-写入统计数据失败
当我尝试测试gwt项目时:
krzysiek@krzysiek-Latitude-D630:~/git$sudojava-jarevosuitte-0.1.1.jar-项目CP/home/krzysiek/planner/AghPlannerProject-target/home/krzysiek/planner/AghPlannerProject/target/AghPlannerProject-1.0-SNAPSHOT/WEB-INF/classes
我得到:
- EvoSuite
- 在target/home/krzysiek/planner/AghPlannerProject/target/AghPlannerProject-1.0-SNAPSHOT/WEB-INF/classes中找到69个匹配的类
- 分析类路径(生成继承树)
- /home/krzysiek/planner/AghPlannerProject
- /home/krzysiek/planner/AghPlannerProject/target/AghPlannerProject-1.0-SNAPSHOT/WEB-INF/classes
- 当前类:pl.edu.agh.planner.server.PlannerServiceImpl
- 将为类生成测试用例:pl.edu.agh.planner.server.PlannerServiceImpl
- 正在启动客户端
- 正在连接到端口11775上的主进程
- 正在分析类路径:
- 从/tmp/ES_heritancetree1562005591350926448.xml.gz加载的继承树
- 找不到测试中的类:pl.edu.agh.planner.server.PlannerServiceImpl:java.lang.ClassNotFoundException:pl/edu/agh/planner/client/PlannerService
org.evosuite.instrumenting.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:185)org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)由以下原因引起:java.lang.NoClassDefFoundError:pl/edu/agh/planner/client/PlannerService
java.lang.ClassLoader.defineClass1(本机方法)
*.lang.ClassLoader.defineCClassorg.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)由以下原因引起:java.lang.ClassNotFoundException:com/google/gwt/user/client/rpc/RemoteService
org.evosuite.instrumenting.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:185)org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)由以下原因引起:java.lang.NoClassDefFoundError:com/google/gwt/user/client/rpc/RemoteService
java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)由以下原因引起:java.lang.ClassNotFoundException:类"com/google/gwt/user/client/rpc/RemoteService.class"应位于目标项目,但找不到
org.evosuite.instrumenting.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:185)org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(Thread.java:745)由以下原因引起:java.lang.ClassNotFoundException:类"com/google/gwt/user/client/rpc/RemoteService.class"应位于目标项目,但找不到
org.evosuite.instrumenting.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:171)org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.ClassLoader.defineClass1org.evosuite.instruction.InstructionClassLoader.loadClass(InstrumentingClassLoader.java:139)java.lang.Class.forName0(Native Method)
java.lang.CClass.forName(Class.java:348)
org.evosuite.Properties.getTargetClassorg.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)java.util.concurrent.FFutureTask.run(FutureTask.java:266)
java.util.conconcurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)java.lang.Thread.run(线程.java:745)- 初始化目标类时出错:未能加载pl.edu.agh.planner.server.PlannerServiceImpl[MASTER]12:01:32.928[pool-1-thread-2]错误TestSuiteGenerator-的问题pl.edu.agh.planner.server.PlannerServiceImpl.完整堆栈:java.lang.RuntimeException:加载失败pl.edu.agh.planner.server.PlannerServiceImplorg.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:411)~[evosuite--0.1.1.jar:na]在org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171)~[evosuite--0.1.1.jar:na]在org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117)~[evosuite--0.1.1.jar:na]在org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerate.java:221)~[evosuite--0.1.1.jar:na]在org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125)[evosuite--0.1.1.jar:na]java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)[na:1.8.0_45]java.util.concurrent.FFutureTask.run(FutureTask.java:266)[na:1.8.0_45]在java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)[na:1.8.0_45]java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)[na:1.8.0_45]
- 计算完成[MASTER]12:01:33.127[main]错误SearchStatistics-由于EvoSuite,未保存任何统计信息未能生成任何测试用例[MASTER]12:01:33.230[main]错误TestGeneration-写入统计数据失败
它似乎找不到类,但我不知道为什么,它在pl/edu/agh/planner/client/中
您需要指定类路径。源文件夹(本例中为src/czytacz)包含.java文件。对于类路径,您需要指定编译的.class文件所在的位置。这取决于你如何编译你的项目(例如,如果你使用Maven,目标/类)