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: [email protected]
For additional commands, e-mail: [email protected]