tiebin-zhang / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Can run eclipse plugin tests #390

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create Junit Test class with either @Runas annotation or rule
2. Execute the test as eclipse plugin test
3. InitialisationError is thrown and stack traces attached

What is the expected output? What do you see instead?
Test should run correctly but produces errors

What version of the product are you using? On what operating system?
linux
eclipse indigo
powermock 1.4.12 (both easymock and mockito versions)

Please provide any additional information below.
Have had all org.powermock jars in the same plugin (nested jars) and tried with 
each jar in separate plugin. Makes no difference.

Tried playing with the current thread's context class loader and this gets a 
little further but everytime a Class.forName is encountered a new 
ClassNotFoundException is thrown.

Have noticed other people have tried to execute tests as eclipse plugin tests. 
Is this officially supported?

Original issue reported on code.google.com by enigm...@googlemail.com on 8 Jun 2012 at 12:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
unit test attached. Very simple but fails to run with exceptions.

runnerTrace.txt is the stack trace generated from the test using @Runas 
annotation. This is due to line 187 in AbstractTestSuiteChunkerImpl:

registerProxyframework(defaultMockLoader); // default class loader of thread

Classloader is neither the test class's classloader or the powermock plugin's 
class loader. Seems to be a random class loader from another plugin (maybe the 
application class loader)

Changing this line to:

registerProxyframework(this.getClass().getClassLoader()); // powermock plugin's 
loader

gets past this exception but then ClassNotFoundExceptions occur later when the 
testChunk's test is attempted to be loaded using the powermock plugin's class 
loader.

The use of Eclipse buddying makes no difference either.

Any thoughts most appreciated.

Original comment by enigm...@googlemail.com on 8 Jun 2012 at 12:35

Attachments:

GoogleCodeExporter commented 9 years ago
This is quite complicated stuff. If you need to use PowerMock inside an Eclipse 
PDE suite then I suggest you to use a Java agent based JUnit rule instead (see 
front page documentation).

Original comment by johan.ha...@gmail.com on 13 Jul 2012 at 7:11