java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger for JUnit test case for Java mail

The javax.mail-api artifact is only good for compiling against. You actually need to run code, so you need a complete implementation of JavaMail API. Use this: <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.6.2</version> </dependency> NOTE: The version number will probably differ. Check the latest version here.