Parameterized tests

ElasTest provides a simple way of defining parameters that will be available on both your SuTs and TJobs as environment variables.

Add parameters to a SuT when creating/editing it:

Add parameters to a TJob when creating/editing it:

Just before running a TJob, a dialog will show the parameters and their current values for both the SuT and the TJob. You can check them, edit them and add new ones before running the TJob.

Parameterizing SuTs and TJobs can give you great advantages. If you are testing an application that makes use of any environment variable, you can easily change its value before running a TJob. And if you actively configure your test code to use environment variables as control mechanisms, it will only take you a couple of clicks in ElasTest to run the same test with different configurations. Let's see how this is reflected in real code in our tests:

Java JS

public class MyTest {

  @Test
  public void test() throws Exception {

    String MY_CUSTOM_PARAM = System.getenv("MY_CUSTOM_PARAM");
    boolean enterIf = Boolean.parseBoolean(MY_CUSTOM_PARAM);

    if (enterIf) {

        // Do something in your test

    } else {

        // Do something different in your test

    }
  }

}

This test is implemented with JUnit. It calls System.getenv method to get the parameter "MY_CUSTOM_PARAM". Depending on its value, our test can perform some actions or others.