# Disable mail functionality for Unit Tests

**URL:** <https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521>\
**Category:** Flowable Engine\
**Created:** [May 3, 2017, 9:20am UTC](https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521 "2017-05-03T09:20:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![donkon](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@donkon](https://forum.flowable.org/u/donkon)\
**Post date:** [May 3, 2017, 9:20am UTC](https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521/1 "2017-05-03T09:20:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [May 3, 2017, 10:01am UTC](https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521/2 "2017-05-03T10:01:28Z")

</div>

Hi,

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

Regards,

Yvo

---

<div class="post-metadata">

**Author:** ![donkon](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@donkon](https://forum.flowable.org/u/donkon)\
**Post date:** [May 3, 2017, 12:02pm UTC](https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521/3 "2017-05-03T12:02:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yvo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/yvo/32/2231_2.png) [@yvo](https://forum.flowable.org/u/yvo)\
**Post date:** [May 3, 2017, 12:20pm UTC](https://forum.flowable.org/t/disable-mail-functionality-for-unit-tests/521/4 "2017-05-03T12:20:58Z")

</div>

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.

> <https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/test/java/org/flowable/engine/test/bpmn/mail/EmailTestCase.java>

Hope this helps.

Yvo
