1

我尝试从命令行使用 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
    • 源代码/czytacz

没有为我的项目创建测试

- - - - - - - - - - - - - - - -编辑 - - - - - - - - - ---------------

谢谢 arcuri82 它解决了我的问题,但我还有另一个问题。

为了:

krzysiek@krzysiek-Latitude-D630:~/git$ sudo java -jar evosuite-0.1.1.jar -projectCP /home/krzysiek/workspace/czytacz -target /home/krzysiek/workspace/czytacz/bin/czytacz

我得到:

  • EvoSuite
  • 在目标 /home/krzysiek/workspace/czytacz/bin/czytacz 中找到 6 个匹配的类
  • 分析类路径(生成继承树)
    • /home/krzysiek/工作区/czytacz
    • /home/krzysiek/工作区/czytacz/bin/czytacz
  • 当前班级:跑步
  • 为类生成测试用例:运行
  • 启动客户端
  • 连接到端口 9969 上的主进程
  • 分析类路径:
  • 从 /tmp/ES_inheritancetree2228980810912137439.xml.gz 加载的继承树
  • 初始化目标类时出错:在继承树 [MASTER] 12:37:11.978 [pool-1-thread-2] 错误 TestSuiteGenerator - 运行问题中找不到目标类。全栈:java.lang.ClassNotFoundException:在 org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:85) ~[evosuite-0.1.1.jar:na] 在 org.evosuite 的继承树中找不到目标类。 TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) ~[evosuite-0.1.1.jar:na] at org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) [evosuite-0.1.1.jar :na] 在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45] 在 java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8 .0_45] 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.
  • 计算完成 [MASTER] 12:37:12.272 [main] ERROR SearchStatistics - 由于 EvoSuite 未能生成任何测试用例,因此未保存统计信息 [MASTER] 12:37:12.374 [main] ERROR TestGeneration - 无法写入统计数据

当我尝试测试 gwt 项目时:

krzysiek@krzysiek-Latitude-D630:~/git$ sudo java -jar evosuite-0.1.1.jar -projectCP /home/krzysiek/planner/AghPlannerProject -target /home/krzysiek/planner/AghPlannerProject/target/AghPlannerProject-1.0-快照/WEB-INF/类

我得到:

  • EvoSuite
  • 在目标 /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_inheritancetree1562005591350926448.xml.gz 加载的继承树
  • 找不到被测类:pl.edu.agh.planner.server.PlannerServiceImpl:java.lang.ClassNotFoundException:pl/edu/agh/planner/client/PlannerService
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java: 185) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.Class.forName0(本机方法)
    java.lang.Class.forName(Class.java:348)
    org.evosuite.Properties.getTargetClass (Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) java .util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.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(Native Method)
    java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    java.lang.ClassLoader.defineClass (ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:348)
    org.evosuite.Properties.getTargetClass(Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup。 TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1 .run(ClientNodeImpl.java:125) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.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.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:185) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java: 139) java.lang.ClassLoader.defineClass1(本机方法)
    java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.Class.forName0(Native Method)
    java.lang.Class.forName (Class.java:348)
    org.evosuite.Properties.getTargetClass(Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) java .util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.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.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    java.lang.ClassLoader .defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.ClassLoader.defineClass1(Native方法)
    java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang。 Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:348)
    org.evosuite.Properties.getTargetClass(Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) java .util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.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.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:185) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass (ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass (ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java :139) java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:348)
    org.evosuite.Properties.getTargetClass(Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite。 setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) java.util.concurrent .Executors$RunnableAdapter.call(Executors.java:511) java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.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.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:171) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass (ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:139) java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClass (ClassLoader.java:760)
    java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    org.evosuite.instrumentation.InstrumentingClassLoader.instrumentClass(InstrumentingClassLoader.java:178) org.evosuite.instrumentation.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java :139) java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:348)
    org.evosuite.Properties.getTargetClass(Properties.java:2086)
    org.evosuite.Properties.getTargetClass(Properties.java:2060)
    org.evosuite.setup.TestClusterGenerator.initializeTargetMethods(TestClusterGenerator.java:405) org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:171) org.evosuite。 setup.DependencyAnalysis.analyze(DependencyAnalysis.java:117) org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:125) java.util.concurrent .Executors$RunnableAdapter.call(Executors.java:511) java.util.concurrent.FutureTask.run(FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent .ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.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:无法在 org.evosuite.setup.TestClusterGenerator.initializeTargetMethods 加载 pl.edu.agh.planner.server.PlannerServiceImpl(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] at org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:221) ~[evosuite-0.1.1.jar:na] at org.evosuite.rmi.service.ClientNodeImpl$1。
  • 计算完成 [MASTER] 12:01:33.127 [main] ERROR SearchStatistics - 由于 EvoSuite 未能生成任何测试用例,因此未保存统计信息 [MASTER] 12:01:33.230 [main] ERROR TestGeneration - 无法写入统计数据

它似乎找不到课程,但我不知道为什么,它在 pl/edu/agh/planner/client/

4

1 回答 1

3

您需要指定类路径。源文件夹(在您的情况下为 src/czytacz)包含 .java 文件。对于类路径,您需要指定编译的 .class 文件的位置。这取决于您如何编译项目(例如,如果您使用 Maven,则为目标/类)

于 2015-04-21T16:18:53.100 回答