Running unit test cases using Maven

You can run unit test cases using Maven, too. In fact, the install target of Maven also runs unit tests. However, it is possible to run only unit tests. To do this, right-click on the project in Package Explorer and select Run As | Maven test.

You might see the following error in the console:

java.lang.NoClassDefFoundError: org/junit/Assert 
  at packt.book.jee.eclipse.ch5.bean.CourseTest.testIsValidCourse 
(CourseTest.java:10) 
Caused by: java.lang.ClassNotFoundException: org.junit.Assert 
  at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
  at java.security.AccessController.doPrivileged(Native Method) 

The reason for this error is that we haven't ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.