Disable mail functionality for Unit Tests

We use heavily JUnit Tests for testing our BPMNs.
Some BPMNs use the Activiti MailTask. This work’s great on our real environment (where we have a mail server), but for the JUnit Tests, we would like to disable the mail functionality.

Is there a way to do this?

Regards,
Björn

Hi,

isn’t it possible to run the unit tests with a ‘test engine config’ where the mail server is stubbed?

Regards,

Yvo

Yes, we have a test engine config, but how do I get the mail server stubbed? If I leave the mail configuration blank (ProcessEngineConfiguration), I get an Connection Refused Exception

Hi.

The actual logic for sending the email is the MailActivityBehavior so you could mock that in your tests.
If you’re really want to unit test in stead of a integration test.

But perhaps better (and easier) is to start a simple mail server in your tests.
Take a look how we do it when testing the MailTask.

Hope this helps.

Yvo