当我试图在这个版本上运行我的单元测试时,我遇到了一个问题。注意:问题仅存在于 Eclipse 中,当我尝试在更高的环境上本地运行时,它工作正常。并且一些不使用 closeablehttpclient 的测试用例运行良好。
PowerMock - powermock-mockito-release-full-1.6.4-full,powermock-module-testng-1.6.6 javaassist - javassist-3.24.0-GA java8
堆栈跟踪-
javassist.CannotCompileException: [source error] cannot find constructor org.apache.http.protocol.RequestUserAgent(java.lang.String)
at javassist.expr.NewExpr.replace(NewExpr.java:235)
at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:418)
at javassist.expr.ExprEditor.loopBody(ExprEditor.java:217)
at javassist.expr.ExprEditor.doit(ExprEditor.java:96)
at javassist.CtClassType.instrument(CtClassType.java:1541)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:252)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)