PowerMock Mockito [PowerMockito] @PrepareForTest – > java. lang.NoClassDefFoundError:javassist / NotFoundException

I'm trying to use my first powermockito [powermockito] simulation in existing JUnit tests

I've narrowed down that when I just have the class level annotation @ preparefortest (and @ runwith (powermockrunner. Class), rather than any actual simulation code), I get Java Lang. NoClassDefFoundError: javassist / notfoundexception: if I comment out @ preparefortest and any actual simulation code to eliminate mixed variables, the error will not occur; If I only UN annotate @ preparefortest, an error will occur So I think this will narrow the problem down to the problem related to trying to use annotations... @ h_ 502_ 3@

I have these jars on my build path: junit-4.11 jaar,junit-addons-1.4. jar,mockito-all-1.9. 5.jar,mockito-all-1.9. 5-sources. jar,powermock-mockito-1.5. 4 full. jar.@ H_ 502_ 3@

powermock-mockito-1.5. 4-full. Jar is the only new version I added to try powermockito (from https://code.google.com/p/powermock/wiki/Downloads?tm=2 Start): it gives me everything I need to write new powermockito simulation code without eclipse compilation errors (I have obtained other mentioned ARS from the previous existing JUnit & mockito [alone, no powermockito] test.) @ h_ 502_ 3@

What can I do wrong with that mistake@ H_ 502_ 3@

Solution

(this almost helped me out)

Very simple solution (I almost started): I missed some powermockito dependent jars (from https://code.google.com/p/powermock/wiki/Downloads?tm=2 (start): specifically {cglib-nodep-2.2.2.jar, javssist-3.18.1-ga.jar, obj enesis - 2.1. Jar}@ H_ 502_ 3@

This is a simple solution. It's a bit stupid. Start from the first, because the powermock google code download page contains all these: 1. When I encounter a problem, I only download and add powermock-mockito-1.5 4 -full. jar; I already have JUnit & mockito jars, so I think this 3 allows me to write powermock code without any compilation errors in eclipse There is a zip powermockito jar dependencies on the google code download page, but it is also said that powerockito jar is provided separately This situation makes it difficult for me to realize that I missed some others, because it seems that I saw everything I need from that angle (thinking I already have the dependencies I need for my existing JUnit and mockito cans)@ H_ 502_ 3@

In fact, the dependent zip has the extra zip needed to solve the problem I should have checked the first carefully, but I didn't realize that I made the opposite wrong assumption@ H_ 502_ 3@

So... The answer is to make sure you get the zip of all dependencies [and add them all to your build path] Finally, I'm a little obvious and stupid, but hey, many software errors and problems are ultimately: simple wrong assumptions or ignored details we don't realize, so it takes some time to implement troubleshooting@ H_ 502_ 3@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>