title: Unit testing a verticle deployment
body: <p>I have a simple Verticle that reads configuration from a properties file and loads in into vertx config. I have written a unit test to test the deployment of this verticle and possible cause of test failure is non availability of the properties file at the location.</p>
  
  <p>When I run the test, unit test passes irrespective of whether I change the properties file name or path and the handler says the verticle was deployed successfully. </p>
  
  <p>Am I doing something wrong here? Below is my code</p>
  
  <pre><code>import io.vertx.config.ConfigRetrieverOptions;
  import io.vertx.config.ConfigStoreOptions;
  import io.vertx.core.DeploymentOptions;
  import io.vertx.core.json.JsonObject;
  import io.vertx.rxjava.config.ConfigRetriever;
  import io.vertx.rxjava.core.AbstractVerticle;
  
  
  /**
   * This is the main launcher verticle, the following operations will be executed in start() method of this verticle:
   * 1. Read configurations from application.properties file
   * 2. Deploy all other verticles in the application
   */
  public class LauncherVerticle extends AbstractVerticle {
  
  
      @Override
      public void start() throws Exception {
  
          //set up configuration from the properties file
          ConfigStoreOptions fileStore = new ConfigStoreOptions()
                  .setType("file")
                  .setFormat("properties")
                  .setConfig(new JsonObject().put("path", System.getProperty("vertex.config.path"));
  
          //create config retriever options add properties to filestore
          ConfigRetrieverOptions options = new ConfigRetrieverOptions().addStore(fileStore);
          ConfigRetriever configRetriever = ConfigRetriever.create(vertx, options);
  
          DeploymentOptions deploymentOptions = new DeploymentOptions();
  
          //Deploy verticles after the config has been loaded
          //The configurations are loaded into JsonConfig object
          //This JsonConfig object can be accessed in other verticles using the config() method.
          configRetriever.rxGetConfig().subscribe(s -&gt; {
  
              //pass on the JsonConfig object to other verticles through deployment options
              deploymentOptions.setConfig(s);
              vertx.deployVerticle(AnotherVerticle.class.getName(), deploymentOptions);
  
          }, e -&gt; {
              log.error("Failed to start application : " + e.getMessage(), e);
              try {
                  stop();
              } catch (Exception e1) {
                  log.error("Unable to stop vertx, terminate the process manually : "+e1.getMessage(), e1);
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>This is my unit test</strong></p>
  
  <pre><code>import io.vertx.ext.unit.TestContext;
  import io.vertx.ext.unit.junit.VertxUnitRunner;
  import io.vertx.rxjava.core.Vertx;
  import org.junit.Assert;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import rx.Single;
  
  
  @RunWith(VertxUnitRunner.class)
  public class LoadConfigurationTest {
  
  
      /**
       * Config should be loaded successfully
       *
       * @param context
       */
      @Test
      public void loadConfigTest(TestContext context) {
          /*
           * Set the system property "vertx.config.path" with value "application.properties"
           * This system property will be used in the Launcher verticle to read the config file
           */
          System.setProperty("vertx.config.path", "/opt/vertx/config/application.properties");
  
          //create vertx instance
          Vertx vertx = Vertx.vertx();
  
          Single&lt;String&gt; single = vertx.rxDeployVerticle(LauncherVerticle.class.getName());
          single.subscribe(s -&gt; {
              vertx.rxUndeploy(s);
          }, e -&gt; {
              Assert.fail(e.getMessage());
          });
  
      }
  
      /**
       * Test for negative use case - file not available in the specified location
       *
       * @param context
       */
      @Test
      public void loadConfigFailTest(TestContext context) {
  
           //set path = non existing path
          System.setProperty("vertx.config.path", "/non/existing/path/application.properties");
  
          //create vertx instance
          Vertx vertx = Vertx.vertx();
  
          Single single = vertx.rxDeployVerticle(LauncherVerticle.class.getName());
  
          single.subscribe(s -&gt; {
              //not executing this statement
              Assert.fail("Was expecting error but Verticle deployed successfully");
          }, e -&gt; {
              //not executing this statement either
              System.out.println("pass");
          });
      }
  }
  </code></pre>