title: How to test async vertx eventbus handlers without sending reply
body: <p>I have two microservices written with java vertx. They communicate via eventbus.
  First one sends a message and second receives the message.</p>
  
  <p><strong>First idea</strong>: Only reply to Vertx eventbus messages in unit test.</p>
  
  <p>I want to test that message is being processed without errors and therefore I write unit test on second microservice that checks the reply</p>
  
  <pre><code>eventbus.send("address", message, reply -&gt; {
      if (reply.succeeded()) {
          context.async().complete();
      } else {
          context.fail();
      }});
  </code></pre>
  
  <p>Now I have to send reply in my consumer, but I want to do it only in test, I do not need to send replies in production. I do not want to consume cpu and network to send replies in production. So what I am looking for is something like this:</p>
  
  <pre><code>vertx.eventBus().consumer("address", handler -&gt; {
      Boolean success = methodMayFail();
      if ( MY_CONTEXT_IS_TEST || HANDLER_IS_LOCAL_AS_I_ONLY_SENT_LOCAL_MESSAGES_FROM_TEST) {
          success ? handler.reply("ok") : handler.fail();
      }
  });
  </code></pre>
  
  <p><strong>Second idea</strong> came after <a href="https://stackoverflow.com/a/36220038/1925717">cdelmas comment</a> and is in <a href="https://stackoverflow.com/a/36373863/1925717">my own answer</a></p>