private static String getHiveRoot() {
    List<String> candidateSiblings = new ArrayList<>();
    if (System.getProperty("hive.root") != null) {
      try {
        candidateSiblings.add(new File(System.getProperty("hive.root")).getCanonicalPath());
      } catch (IOException e) {
        throw new RuntimeException("error getting hive.root", e);
      }
    }
    candidateSiblings.add(new File(".").getAbsolutePath());

    for (String string : candidateSiblings) {
      File curr = new File(string);
      do {
        Set<String> lls = Sets.newHashSet(curr.list());
        if (lls.contains("itests") && lls.contains("ql") && lls.contains("metastore")) {
          System.out.println("detected hiveRoot: " + curr);
          return ensurePathEndsInSlash(curr.getAbsolutePath());
        }
        curr = curr.getParentFile();
      } while (curr != null);
    }
    throw new RuntimeException("unable to find hiveRoot");
  }
Helps in setting up environments to run high level hive tests

For a sample testcase see {@link TestHiveTestEnvSetup}!
Because setting up such a complex environment is a bit more sophisticated than it should;
this class introduces some helper concepts beyond what juni4 has

<ul>
 <li>parts are decomposed into smaller {@link IHiveTestRule}
 <li>{@link HiveTestEnvContext} is visible to every methodcall</li>
 <li>invocation order of before calls are "forward"
 <li>invocation order of before calls are "backward"
 </ul>


Later this should be migrated to junit5...when it will be possible; see HIVE-18495
ql/src/test/org/apache/hive/testutils/HiveTestEnvSetup.java