title: Testing multiple environments with different data - best practice
body: <p>I need to be able to run the same tests on different environments (max 3) but with different data for each one.</p>
  
  <p>I have a test method:</p>
  
  <pre><code>@Test (groups = "core", description = "Login: Valid log in")
  public void validLogin() {
      User user = UserData.user_2();
      loginPage.logOn(user);
  }
  </code></pre>
  
  <p>In the UserData class I have:</p>
  
  <pre><code>public static User user_2() {
      return new User().newUser("user2", "password");
  }
  </code></pre>
  
  <p>"user2" does not exist on all environments.  I may not be able to change the data that is available on all of the environments to match the test data.</p>
  
  <p>The tests will be executed either using Maven and TestNg so I can send in the parameter for the execution environment.</p>
  
  <p>My initial thought is to use:</p>
  
  <pre><code>public static User user_2() {
      switch(env) {
      case "env1": return new User().newUser("user2", "password"); break;
      case "env2": return new User().newUser("user2Z", "password"); break;
      case "env3": return new User().newUser("user2X", "password"); break;
  }
  </code></pre>
  
  <p>I have a limited number of data classes and methods (&lt;100) but several thousand tests.</p>
  
  <p>What is the best way of setting up and handling the data required for testing against the different environments?</p>