I'm finding the TestNG plugin to be a bit flaky. For example I have a few
tests defined in a couple of classes and I wanted to add a new test class so
I created a new class:
package com.pingmenow.services;
import org.testng.annotations.Test;
public class DummyTest {
@Test
public void dummyTest() {
assert 1 == 2;
}
}
I saved this under src/test/java/com/pingmenow/services/DummyTest.java
(alongside my other test classes) but when I execute mvn test it skips this
class:
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Building pingmenow Tapestry 5 Application
[INFO] task-segment: [test]
[INFO]
------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 10 resources
[INFO] [javarebel:generate {execution: generate-rebel-xml}]
[INFO] Processing com.pingmenow:pingmenow with packaging war
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered
resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory:
/Users/toby/Documents/workspace/pingmenow/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
...
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.463 sec
Results :
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
[INFO] support.GenericApplicationContext Closing
org.springframework.context.support.genericapplicationcont...@af7c57:
display name
[org.springframework.context.support.genericapplicationcont...@af7c57];
startup date [Mon Sep 28 16:03:29 BST 2009]; root of context hierarchy
[INFO] support.DefaultListableBeanFactory Destroying singletons in
org.springframework.beans.factory.support.defaultlistablebeanfact...@cbc2d3:
defining beans
[org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,sessionFactory,hibernateTemplate,dataSource,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,propertyPlaceholderConfigurer,serverService];
root of factory hierarchy
[INFO] hibernate3.LocalSessionFactoryBean Closing Hibernate SessionFactory
[INFO] impl.SessionFactoryImpl closing
[INFO] hbm2ddl.SchemaExport Running hbm2ddl schema export
[INFO] hbm2ddl.SchemaExport exporting generated schema to database
[INFO] hbm2ddl.SchemaExport schema export complete
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Mon Sep 28 16:03:31 BST 2009
[INFO] Final Memory: 12M/22M
[INFO]
------------------------------------------------------------------------
I'm running maven 2.2.0:
Apache Maven 2.2.0 (r788681; 2009-06-26 14:04:01+0100)
Java version: 1.5.0_20
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.5.8" arch: "i386" Family: "unix"
My pom.xml looks like this:
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pingmenow</groupId>
<artifactId>pingmenow</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>pingmenow Tapestry 5 Application</name>
<dependencies>
<!--
A dependency on either JUnit or TestNG is required, or the
surefire
plugin (which runs the tests) will fail, preventing Maven from
packaging the WAR. Tapestry includes a large number of testing
facilities designed for use with TestNG (http://testng.org/), so
it's
recommended.
-->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
...
</project>
Does anyone have any pointers? Thanks!