简体   繁体   中英

How can I fix the NoClassDefFoundError error that occurs when using evosuite to generate test cases?

I got this error when I used evosuite to generate test cases with my android project.

In the beginning, there was such an error:“can not find this class:android.support.v7.widget.Toolbar” I solved this problem by adding Android's jar package:collections-28.0.0.jar into CP path, and then the following error occurred in the process of automatically generating use cases for multiple files:

[MASTER] 21:22:39.979 [logback-2] ERROR TestClusterGenerator - Problem for com.rapidapp.base.account.AppBaseService. Failed to add dependencies for class android.support.v7.widget.Toolbar: java.lang.NoClassDefFoundError: android/support/v7/widget/Toolbar$SavedState [java.lang.Class.getDeclaringClass0(Native Method), java.lang.Class.getDeclaringClass(Class.java:1235), java.lang.Class.getEnclosingClass(Class.java:1277), java.lang.Class.getSimpleBinaryName(Class.java:1443), java.lang.Class.getSimpleName(Class.java:1309), java.lang.Class.isAnonymousClass(Class.java:1411), org.evosuite.setup.TestUsageChecker.canUse(TestUsageChecker.java:155), org.evosuite.setup.TestUsageChecker.canUse(TestUsageChecker.java:338), org.evosuite.setup.TestClusterGenerator.addDependencyClass(TestClusterGenerator.java:975), org.evosuite.setup.TestClusterGenerator.resolveDependencies(TestClusterGenerator.java:358), org.evosuite.setup.TestClusterGenerator.generateCluster(TestClusterGenerator.java:137), org.evosuite.setup.DependencyAnalysis.analyze(DependencyAnalysis.java:118), org.evosuite.setup.DependencyAnalysis.analyzeClass(De pendencyAnalysis.java:132), org.evosuite.TestSuiteGenerator.initializeTargetClass(TestSuiteGenerator.java:110), org.evosuite.TestSuiteGenerator.generateTestSuite(TestSuiteGenerator.java:130), org.evosuite.rmi.service.ClientNodeImpl$1.run(ClientNodeImpl.java:145), 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)]

Finally, a use case is not generated.

I have experienced This exception before, when (trying) to run code which had been compiled on one operating system on another. Also, when updates have occurred to the OS.

Though you might have thought that backwards compatibility should remove this later, it is not always the case!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM