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?
isn’t it possible to run the unit tests with a ‘test engine config’ where the mail server is stubbed?
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
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.
This file has been truncated.
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* @author Joram Barrez
Hope this helps.