Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Junit Email Tests Without Emails Actually Going Out

I want to run unit tests (Junit) on some model classes that typically will send emails confirming that things happened. Is there a mock email server that you can use with unit tests that will let you confirmation that your run tried to send an email without actually sending the emails out?

This seems like it would be a nice to have, just not sure I want to write my own. The app stack for the emailing aspect is Velocity+Spring, so it would be preferable if the test server can be pointed at by simply changing the applicationContext.xml file.

like image 614
stevedbrown Avatar asked Jun 22 '09 14:06

stevedbrown


People also ask

Why is JUnit test ignored?

The @Ignore annotation helps in this scenario. A test method annotated with @Ignore will not be executed. If a test class is annotated with @Ignore, then none of its test methods will be executed.

Does JUnit provide input cases automatically?

JUnit tests can be run automatically and they check their own results and provide immediate feedback.

Do JUnit tests need to be public?

Creating a New Test Class We can create a new test class by simply creating a public class. Even though there is no “official” naming convention, the most common way to name a unit test class is to add the suffix Test to the name of the tested class or unit. JUnit 4 requires that all test classes are public .


1 Answers

Alternative answer: Dumbster is a fake SMTP server designed for testing against. It's written in Java.

like image 171
Colin Pickard Avatar answered Oct 14 '22 08:10

Colin Pickard