Unable to debug test code in eclipse when using PowerMockRule

1,542 views
Skip to first unread message

moldowan

unread,
Dec 1, 2011, 4:15:15 PM12/1/11
to PowerMock
Hi!

I came accross a nasty little problem:

When using powermock (in conjunction with mockito) with
PowerMockRunner, I can debug code in the test class using eclipse just
fine, breakpoints are respected as expected.

But when I use PowerMockRule instead of PowerMockRunner, eclipse will
not stop at the very same breakpoint in the test class. Breakpoints in
the code being tested are working as expected.

I can provide a simple maven project that can be imported into eclipse
to demonstrate the problem.

Debugging in eclipse by attaching to maven-surefire-plugin also
doesn't work as expected.

Anyone else having this problem?

Best regards.

Johan Haleby

unread,
Dec 2, 2011, 3:21:31 AM12/2/11
to powe...@googlegroups.com
Hi,

Which rule are you using, the classloader based or the java agent based? I'm using intellij and I've not run into this issue afaik.

/Johan


--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To post to this group, send email to powe...@googlegroups.com.
To unsubscribe from this group, send email to powermock+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/powermock?hl=en.


moldowan

unread,
Dec 2, 2011, 6:06:28 AM12/2/11
to PowerMock
Hi Johan,

There are two rules? I only know this one:
org.powermock.modules.junit4.rule.PowerMockRule

It doesn't make a difference whether I use -javaagent:.../powermock-
module-javaagent-1.4.10.jar or not.

Btw: Powermock 1.4.10, Eclipse 3.7.1 (Eclipse Indigo SR1), Java 1.6u29

ejaenv

unread,
Apr 2, 2014, 10:43:15 AM4/2/14
to powe...@googlegroups.com
I also had this issue. I 've noticed that is caused by the @PrepareForTest at the class. A workaround I use is to move the @PrepareForTest from the class to the method. This allows me to debug in many cases

Johan Haleby

unread,
Apr 3, 2014, 1:04:59 AM4/3/14
to powe...@googlegroups.com
Is this something new? Did it work in older versions? Could it be a Javassist issue?


--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powermock+...@googlegroups.com.

To post to this group, send email to powe...@googlegroups.com.

Akash Borkar

unread,
May 31, 2016, 12:55:27 AM5/31/16
to PowerMock
I am facing same issue. I am using JDK 8. Is there any update / solution for this?

santosh uttam

unread,
Jul 21, 2016, 10:10:04 AM7/21/16
to PowerMock
I am also facing same issue with PowerMockRule, Is there any solloution?

Arthur Zagretdinov

unread,
Jul 26, 2016, 3:50:59 PM7/26/16
to powe...@googlegroups.com
Hello 

I think there is no solution. I faced the same issue in Intellij Idea. Root cause is that when PowerMock Rule is used the classes is reloaded during test starting. And Eclipse/Idea cannot detect that classes have been changed and wait breakpoint on class which not invoked. 


Best regrads,
Arthur Zagretdinov
Reply all
Reply to author
Forward
0 new messages