PowerMock Maven Integration not working

23 views
Skip to first unread message

pokkie

unread,
Feb 22, 2010, 5:31:54 AM2/22/10
to PowerMock
Hi,

I am trying to use PowerMock to mock a static method. I was reading
the MockStatic wiki page, http://code.google.com/p/powermock/wiki/MockStatic
, and there it says that you have to include the @PrepareForTest
annotation whenever you want to mock out a static method call.

However, when I follow the instructions on the EasyMock_Maven
integration wikipage, http://code.google.com/p/powermock/wiki/EasyMock_maven
, it says that I need to include 2 dependencies.

1. <artifactId>powermock-module-junit4</artifactId>
2. <artifactId>powermock-api-easymock</artifactId>

However, none of these jar files includes the @PrepareForTest
annotation and so I am unable to compile my PowerMock testcase.

So, 2 questions:

1. What do I need to add to my pom file to make it work? I tried to
add powermock-core but had no luck with that

2. Can the documentation please be updated to reflect the correct
approach in the case that it is not correct?

In the event that I am missing something, please let me know :)

Regards,
-- pok

umesh kathiriya

unread,
Feb 22, 2010, 6:28:37 AM2/22/10
to powe...@googlegroups.com
Use powermock with all dependencies


--
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.


Johan Haleby

unread,
Feb 22, 2010, 6:30:35 AM2/22/10
to powe...@googlegroups.com
Hi,

It should be enough to depend on those two artifacts if you're using Maven. The transitive dependencies should be resolved and downloaded automatically. "PrepareForTest" is located in package "org.powermock.core.classloader.annotations" in powermock-core. It works fine for me and no one else have reported this before so I assume it's a local issue at your place. Have you added the powermock repository in your pom? You haven't disabled downloading of transitive dependencies?

/Johan

Johan Haleby

unread,
Feb 22, 2010, 6:35:02 AM2/22/10
to powe...@googlegroups.com
I did found a small issue on the getting started pages for EasyMock and Mockito when using Maven. They weren't updated to version 1.3.5, they still used 1.3.1, which is not the latest version. I've corrected this now but that shouldn't matter I think. You could try again though.

/Johan

pokkie

unread,
Feb 22, 2010, 7:56:04 AM2/22/10
to PowerMock
>It should be enough to depend on those two artifacts if you're using Maven.
>The transitive dependencies should be resolved and downloaded automatically.
> "PrepareForTest" is located in package

Ahh, I am behind a firewall at work, so I tried the manual download
approach and the transitive dependencies didn't kick in.

All sorted now - Thank you

On Feb 22, 1:30 pm, Johan Haleby <johan.hal...@gmail.com> wrote:
> Hi,
>
> It should be enough to depend on those two artifacts if you're using Maven.
> The transitive dependencies should be resolved and downloaded automatically.
> "PrepareForTest" is located in package
> "org.powermock.core.classloader.annotations" in powermock-core. It works
> fine for me and no one else have reported this before so I assume it's a
> local issue at your place. Have you added the powermock repository in your
> pom? You haven't disabled downloading of transitive dependencies?
>
> /Johan
>

> On Mon, Feb 22, 2010 at 12:28 PM, umesh kathiriya <umesh...@gmail.com>wrote:
>
> > Use powermock with all dependencies
>

> >> powermock+...@googlegroups.com<powermock%2Bunsu...@googlegroups.com>


> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/powermock?hl=en.
>
> >  --
> > 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<powermock%2Bunsu...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages