Maven ignores unit test with JUnit and TestNG

Today I was trying to use JUnit 4, and JUnit 3 in a Maven archetype I was creating. I had previously added TestNG dependencies to this project. I then added JUnit in addition to the TestNG.

I run mvn test and no unit tests where run. Strange! I did not get any errors even using the -e error stack trace flag.

I could run the tests through Eclipse just fine, but not through my command line either with a DOS command prompt, or Cygwin.

Here is what my dependencies looked like:

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>

I then commented out my TestNG dependencies:

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<!-- <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency> -->

And my tests started working again just fine.

Not sure the reason, but it appears that JUNit 4 and TestNG 5.8 do not mix well in Maven. Even though I did not have any TestNG tests to be executed.

VN:F [1.9.1_1087]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.1_1087]
Rating: 0 (from 0 votes)
  • Share/Bookmark

This entry was posted on Friday, January 16th, 2009 at 6:21 am and is filed under Java-JavaEE-J2EE. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.