You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "KARR, DAVID" <dk...@att.com> on 2013/01/21 00:54:33 UTC

PowerMock tests work fine in Eclipse, but don't execute in Maven build

I normally use Mockito and JUnit with Maven.  I'm trying to write some tests using PowerMock.  I got the PowerMock test working fine in Eclipse, but now I'm noticing that the test is not running in the Maven build.  Maven finds the test class, but it seems to think there are no tests.  It's also trying to run it with TestNG instead of JUnit, which is surprising.

This is the build output I see:
----------------------
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.foo.tv.client.UiFeatureManagerTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@76cbf7
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.69 sec

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
---------------------------

My very elided test class looks like this:
------------------------
@RunWith(PowerMockRunner.class)
@PrepareForTest({...})
public class UiFeatureManagerTest {

    private UiFeatureManager    uiFeatureManager;
    
...
    
    @Before
    public void setup() {
        uiFeatureManager    = new UiFeatureManager(...);
        ...
        PowerMockito.mockStatic(Blio.class, OrderUtil.class);
    }

    @Test
    public void lookupstuff() {
        when(...).thenReturn(...);
        ...
    }
-------------------

This is my entire POM:
-----------------------------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>powermockdemo</groupId>
    <artifactId>powermockdemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <failIfNoTests>true</failIfNoTests>
                    <parallel>methods</parallel>
                    <detail>true</detail>
                    <additionalClasspathElements>
                        <additionalClasspathElement>src/test/resources</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/classes</additionalClasspathElement>
                        <additionalClasspathElement>${project.build.directory}/test-classes</additionalClasspathElement>
                    </additionalClasspathElements>
                    <argLine>${surefire.argLine}</argLine>
                    <classesDirectory>${project.build.directory}/generated-classes/classes</classesDirectory>
                    <forkMode>once</forkMode>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-mockito-release-full</artifactId>
            <version>1.5</version>
            <classifier>full</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert</artifactId>
            <version>1.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
--------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: PowerMock tests work fine in Eclipse, but don't execute in Maven build

Posted by "KARR, DAVID" <dk...@att.com>.
Thanks.  I discovered I was using the wrong artifacts.  I missed the instructions on another PowerMock doc page.

> -----Original Message-----
> From: bmathus@gmail.com [mailto:bmathus@gmail.com] On Behalf Of Baptiste
> MATHUS
> Sent: Sunday, January 20, 2013 10:05 PM
> To: Maven Users List
> Subject: Re: PowerMock tests work fine in Eclipse, but don't execute in Maven
> build
> 
> Seems like you should in fact not use that artifact.
> http://code.google.com/p/powermock/issues/detail?id=386
> 
> Cheers
> Le 21 janv. 2013 06:56, "Baptiste MATHUS" <ml...@batmat.net> a écrit :
> 
> > Hi,
> > If you could push your demo project somewhere like on github, maybe we can
> > help help you more easily.
> >
> > Just a small guess: isn't powermock "full" some special jar embedding 3rd
> > Party code like testng and that would get selected?
> >
> > Cheers
> > Le 21 janv. 2013 00:55, "KARR, DAVID" <dk...@att.com> a écrit :
> >
> >> I normally use Mockito and JUnit with Maven.  I'm trying to write some
> >> tests using PowerMock.  I got the PowerMock test working fine in Eclipse,
> >> but now I'm noticing that the test is not running in the Maven build.
> >>  Maven finds the test class, but it seems to think there are no tests.
> >>  It's also trying to run it with TestNG instead of JUnit, which is
> >> surprising.
> >>
> >> This is the build output I see:
> >> ----------------------
> >> -------------------------------------------------------
> >>  T E S T S
> >> -------------------------------------------------------
> >> Running com.foo.tv.client.UiFeatureManagerTest
> >> Configuring TestNG with:
> >> org.apache.maven.surefire.testng.conf.TestNG652Configurator@76cbf7
> >> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.69 sec
> >>
> >> Results :
> >>
> >> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
> >> ---------------------------
> >>
> >> My very elided test class looks like this:
> >> ------------------------
> >> @RunWith(PowerMockRunner.class)
> >> @PrepareForTest({...})
> >> public class UiFeatureManagerTest {
> >>
> >>     private UiFeatureManager    uiFeatureManager;
> >>
> >> ...
> >>
> >>     @Before
> >>     public void setup() {
> >>         uiFeatureManager    = new UiFeatureManager(...);
> >>         ...
> >>         PowerMockito.mockStatic(Blio.class, OrderUtil.class);
> >>     }
> >>
> >>     @Test
> >>     public void lookupstuff() {
> >>         when(...).thenReturn(...);
> >>         ...
> >>     }
> >> -------------------
> >>
> >> This is my entire POM:
> >> -----------------------------
> >> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> >> http://www.w3.org/2001/XMLSchema-instance"
> >>     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> >> http://maven.apache.org/xsd/maven-4.0.0.xsd">
> >>     <modelVersion>4.0.0</modelVersion>
> >>     <groupId>powermockdemo</groupId>
> >>     <artifactId>powermockdemo</artifactId>
> >>     <version>0.0.1-SNAPSHOT</version>
> >>     <build>
> >>         <plugins>
> >>             <plugin>
> >>                 <artifactId>maven-compiler-plugin</artifactId>
> >>                 <version>2.3.2</version>
> >>                 <configuration>
> >>                     <source>1.6</source>
> >>                     <target>1.6</target>
> >>                 </configuration>
> >>             </plugin>
> >>             <plugin>
> >>                 <groupId>org.apache.maven.plugins</groupId>
> >>                 <artifactId>maven-surefire-plugin</artifactId>
> >>                 <version>2.12.4</version>
> >>                 <configuration>
> >>                     <failIfNoTests>true</failIfNoTests>
> >>                     <parallel>methods</parallel>
> >>                     <detail>true</detail>
> >>                     <additionalClasspathElements>
> >>
> >>
> <additionalClasspathElement>src/test/resources</additionalClasspathElement>
> >>
> >>
> <additionalClasspathElement>${project.build.directory}/classes</additionalCla
> sspathElement>
> >>
> >> <additionalClasspathElement>${project.build.directory}/test-
> classes</additionalClasspathElement>
> >>                     </additionalClasspathElements>
> >>                     <argLine>${surefire.argLine}</argLine>
> >>
> >> <classesDirectory>${project.build.directory}/generated-
> classes/classes</classesDirectory>
> >>                     <forkMode>once</forkMode>
> >>                 </configuration>
> >>             </plugin>
> >>         </plugins>
> >>     </build>
> >>     <dependencies>
> >>         <dependency>
> >>             <groupId>commons-collections</groupId>
> >>             <artifactId>commons-collections</artifactId>
> >>             <version>3.2.1</version>
> >>         </dependency>
> >>         <dependency>
> >>             <groupId>commons-lang</groupId>
> >>             <artifactId>commons-lang</artifactId>
> >>             <version>2.6</version>
> >>         </dependency>
> >>         <dependency>
> >>             <groupId>org.powermock</groupId>
> >>             <artifactId>powermock-mockito-release-full</artifactId>
> >>             <version>1.5</version>
> >>             <classifier>full</classifier>
> >>             <scope>test</scope>
> >>         </dependency>
> >>         <dependency>
> >>             <groupId>org.easytesting</groupId>
> >>             <artifactId>fest-assert</artifactId>
> >>             <version>1.4</version>
> >>             <scope>test</scope>
> >>         </dependency>
> >>         <dependency>
> >>             <groupId>junit</groupId>
> >>             <artifactId>junit</artifactId>
> >>             <version>4.11</version>
> >>             <scope>test</scope>
> >>         </dependency>
> >>     </dependencies>
> >> </project>
> >> --------------------
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>

Re: PowerMock tests work fine in Eclipse, but don't execute in Maven build

Posted by Baptiste MATHUS <ml...@batmat.net>.
Seems like you should in fact not use that artifact.
http://code.google.com/p/powermock/issues/detail?id=386

Cheers
Le 21 janv. 2013 06:56, "Baptiste MATHUS" <ml...@batmat.net> a écrit :

> Hi,
> If you could push your demo project somewhere like on github, maybe we can
> help help you more easily.
>
> Just a small guess: isn't powermock "full" some special jar embedding 3rd
> Party code like testng and that would get selected?
>
> Cheers
> Le 21 janv. 2013 00:55, "KARR, DAVID" <dk...@att.com> a écrit :
>
>> I normally use Mockito and JUnit with Maven.  I'm trying to write some
>> tests using PowerMock.  I got the PowerMock test working fine in Eclipse,
>> but now I'm noticing that the test is not running in the Maven build.
>>  Maven finds the test class, but it seems to think there are no tests.
>>  It's also trying to run it with TestNG instead of JUnit, which is
>> surprising.
>>
>> This is the build output I see:
>> ----------------------
>> -------------------------------------------------------
>>  T E S T S
>> -------------------------------------------------------
>> Running com.foo.tv.client.UiFeatureManagerTest
>> Configuring TestNG with:
>> org.apache.maven.surefire.testng.conf.TestNG652Configurator@76cbf7
>> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.69 sec
>>
>> Results :
>>
>> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
>> ---------------------------
>>
>> My very elided test class looks like this:
>> ------------------------
>> @RunWith(PowerMockRunner.class)
>> @PrepareForTest({...})
>> public class UiFeatureManagerTest {
>>
>>     private UiFeatureManager    uiFeatureManager;
>>
>> ...
>>
>>     @Before
>>     public void setup() {
>>         uiFeatureManager    = new UiFeatureManager(...);
>>         ...
>>         PowerMockito.mockStatic(Blio.class, OrderUtil.class);
>>     }
>>
>>     @Test
>>     public void lookupstuff() {
>>         when(...).thenReturn(...);
>>         ...
>>     }
>> -------------------
>>
>> This is my entire POM:
>> -----------------------------
>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance"
>>     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>>     <modelVersion>4.0.0</modelVersion>
>>     <groupId>powermockdemo</groupId>
>>     <artifactId>powermockdemo</artifactId>
>>     <version>0.0.1-SNAPSHOT</version>
>>     <build>
>>         <plugins>
>>             <plugin>
>>                 <artifactId>maven-compiler-plugin</artifactId>
>>                 <version>2.3.2</version>
>>                 <configuration>
>>                     <source>1.6</source>
>>                     <target>1.6</target>
>>                 </configuration>
>>             </plugin>
>>             <plugin>
>>                 <groupId>org.apache.maven.plugins</groupId>
>>                 <artifactId>maven-surefire-plugin</artifactId>
>>                 <version>2.12.4</version>
>>                 <configuration>
>>                     <failIfNoTests>true</failIfNoTests>
>>                     <parallel>methods</parallel>
>>                     <detail>true</detail>
>>                     <additionalClasspathElements>
>>
>> <additionalClasspathElement>src/test/resources</additionalClasspathElement>
>>
>> <additionalClasspathElement>${project.build.directory}/classes</additionalClasspathElement>
>>
>> <additionalClasspathElement>${project.build.directory}/test-classes</additionalClasspathElement>
>>                     </additionalClasspathElements>
>>                     <argLine>${surefire.argLine}</argLine>
>>
>> <classesDirectory>${project.build.directory}/generated-classes/classes</classesDirectory>
>>                     <forkMode>once</forkMode>
>>                 </configuration>
>>             </plugin>
>>         </plugins>
>>     </build>
>>     <dependencies>
>>         <dependency>
>>             <groupId>commons-collections</groupId>
>>             <artifactId>commons-collections</artifactId>
>>             <version>3.2.1</version>
>>         </dependency>
>>         <dependency>
>>             <groupId>commons-lang</groupId>
>>             <artifactId>commons-lang</artifactId>
>>             <version>2.6</version>
>>         </dependency>
>>         <dependency>
>>             <groupId>org.powermock</groupId>
>>             <artifactId>powermock-mockito-release-full</artifactId>
>>             <version>1.5</version>
>>             <classifier>full</classifier>
>>             <scope>test</scope>
>>         </dependency>
>>         <dependency>
>>             <groupId>org.easytesting</groupId>
>>             <artifactId>fest-assert</artifactId>
>>             <version>1.4</version>
>>             <scope>test</scope>
>>         </dependency>
>>         <dependency>
>>             <groupId>junit</groupId>
>>             <artifactId>junit</artifactId>
>>             <version>4.11</version>
>>             <scope>test</scope>
>>         </dependency>
>>     </dependencies>
>> </project>
>> --------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

Re: PowerMock tests work fine in Eclipse, but don't execute in Maven build

Posted by Baptiste MATHUS <ml...@batmat.net>.
Hi,
If you could push your demo project somewhere like on github, maybe we can
help help you more easily.

Just a small guess: isn't powermock "full" some special jar embedding 3rd
Party code like testng and that would get selected?

Cheers
Le 21 janv. 2013 00:55, "KARR, DAVID" <dk...@att.com> a écrit :

> I normally use Mockito and JUnit with Maven.  I'm trying to write some
> tests using PowerMock.  I got the PowerMock test working fine in Eclipse,
> but now I'm noticing that the test is not running in the Maven build.
>  Maven finds the test class, but it seems to think there are no tests.
>  It's also trying to run it with TestNG instead of JUnit, which is
> surprising.
>
> This is the build output I see:
> ----------------------
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running com.foo.tv.client.UiFeatureManagerTest
> Configuring TestNG with:
> org.apache.maven.surefire.testng.conf.TestNG652Configurator@76cbf7
> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.69 sec
>
> Results :
>
> Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
> ---------------------------
>
> My very elided test class looks like this:
> ------------------------
> @RunWith(PowerMockRunner.class)
> @PrepareForTest({...})
> public class UiFeatureManagerTest {
>
>     private UiFeatureManager    uiFeatureManager;
>
> ...
>
>     @Before
>     public void setup() {
>         uiFeatureManager    = new UiFeatureManager(...);
>         ...
>         PowerMockito.mockStatic(Blio.class, OrderUtil.class);
>     }
>
>     @Test
>     public void lookupstuff() {
>         when(...).thenReturn(...);
>         ...
>     }
> -------------------
>
> This is my entire POM:
> -----------------------------
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd">
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>powermockdemo</groupId>
>     <artifactId>powermockdemo</artifactId>
>     <version>0.0.1-SNAPSHOT</version>
>     <build>
>         <plugins>
>             <plugin>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>2.3.2</version>
>                 <configuration>
>                     <source>1.6</source>
>                     <target>1.6</target>
>                 </configuration>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-surefire-plugin</artifactId>
>                 <version>2.12.4</version>
>                 <configuration>
>                     <failIfNoTests>true</failIfNoTests>
>                     <parallel>methods</parallel>
>                     <detail>true</detail>
>                     <additionalClasspathElements>
>
> <additionalClasspathElement>src/test/resources</additionalClasspathElement>
>
> <additionalClasspathElement>${project.build.directory}/classes</additionalClasspathElement>
>
> <additionalClasspathElement>${project.build.directory}/test-classes</additionalClasspathElement>
>                     </additionalClasspathElements>
>                     <argLine>${surefire.argLine}</argLine>
>
> <classesDirectory>${project.build.directory}/generated-classes/classes</classesDirectory>
>                     <forkMode>once</forkMode>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
>     <dependencies>
>         <dependency>
>             <groupId>commons-collections</groupId>
>             <artifactId>commons-collections</artifactId>
>             <version>3.2.1</version>
>         </dependency>
>         <dependency>
>             <groupId>commons-lang</groupId>
>             <artifactId>commons-lang</artifactId>
>             <version>2.6</version>
>         </dependency>
>         <dependency>
>             <groupId>org.powermock</groupId>
>             <artifactId>powermock-mockito-release-full</artifactId>
>             <version>1.5</version>
>             <classifier>full</classifier>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>org.easytesting</groupId>
>             <artifactId>fest-assert</artifactId>
>             <version>1.4</version>
>             <scope>test</scope>
>         </dependency>
>         <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.11</version>
>             <scope>test</scope>
>         </dependency>
>     </dependencies>
> </project>
> --------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>