Too many variants to take in considerations which usually lead to an high instability of the tests.
Let say we have a front end application sending messages to a distribution engine which then forward the messages to other remote destinations. Sounds familiar?
OK so, how you test that messages travelling correctly trough all the predefined servers?
What if I want to keep my tests independent from any integration framework?
My solution is in the logs.
Why not rely on the logs to prove that your application is working as expected?
Logs are often underrated for performance/acceptance/smoke tests, but if correctly written, they can provide all the information you need to measure the status of your software at any point of its execution.
Testing relying on logs is a non intrusive way to test and no performances or anything will be affected. Applying this concept to an hypothetical integration test it's easy (at least in UNIX environments :) ), thanks to libraries like Grep4j:
import static org.grep4j.core.Grep4j.grep; import static org.grep4j.core.Grep4j.regularExpression; import static org.grep4j.core.fluent.Dictionary.on; import static org.grep4j.core.fluent.Dictionary.executing; ... @Test public void aCreateMessageShouldPassThroughAllTheFinalDestinations() { List profiles = Arrays.asList(distributionServerLog(), destination1ServerLog(), destination2ServerLog(), destination3ServerLog()); assertThat(executing(grep(regularExpression("MessageId(.*)Received"), on(profiles))).totalLines(), is(4));} |