Alex Rivera | Logout

Running Junit & PowerMock with Mockito through PowerMockRunner from maven

Asked 2009-11-25T13:14:54.360
9

I am not being able to run Powermock through maven. I'm the PowerMock Mockito and PowerMockRunner for driving a jUnit test.

Here's the test:

@RunWith(PowerMockRunner.class)
@PrepareForTest( { UserLocalServiceUtil.class, ExpandoBridge.class })
public class AlertNotificationsTest {
//...

I haven't configured anyting special for running the test. My pom references the following deps:

  • org.mockito | mockito-all | 1.8.0
  • junit | junit | 4.6.0
  • org.powermock.modules | powermock-module-junit4 | 1.3.1
  • org.powermock.api | powermock-api-mockito | 1.3.1

when I run mvn -Dtest=AlertNotificationsTest test mvn says there's no test to run. But if I run the same test class from eclipse, everything runs ok.

Am I doing something wrong?


Here's my pom.xml below (the relevant parts)

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>5.9</version>
        <classifier>jdk15</classifier>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.6</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock.modules</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.3.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock.api</
Edit
Report

1 Answer

1

Powermock setup looks Ok to me, and the jars seem fine (assuming maven transitive dependencies get the other powermock jars - we have about 6-7 after our ivy resolve gets them)

Eclipse might be using it's own "internal" JUnit library, thus the different behaviours ?

Are the test annotated with org.junit.@Test ?

answered 2009-11-25T13:50:38.457

Your Answer