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.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense

Archives

Newsletter