private static String buildAndRunFromLocalBase(
      Path projectRoot, String targetImage, String baseImage, boolean buildTwice)
      throws VerificationException, IOException, InterruptedException {
    Verifier verifier = new Verifier(projectRoot.toString());
    verifier.setSystemProperty("jib.useOnlyProjectCache", "true");
    verifier.setSystemProperty("_TARGET_IMAGE", targetImage);
    verifier.setSystemProperty("_BASE_IMAGE", baseImage);
    verifier.setSystemProperty("jib.allowInsecureRegistries", "true");
    verifier.setAutoclean(false);
    verifier.addCliOption("-X");
    verifier.addCliOption("--file=pom-localbase.xml");
    verifier.executeGoals(Arrays.asList("clean", "compile"));
    if (!buildTwice) {
      verifier.executeGoal("jib:build");
      return pullAndRunBuiltImage(targetImage);
    }

    verifier.executeGoal("jib:build");
    float timeOne = getBuildTimeFromVerifierLog(verifier);

    verifier.resetStreams();
    verifier.executeGoal("jib:build");
    float timeTwo = getBuildTimeFromVerifierLog(verifier);

    // The first build should take longer than the second build.
    assertThat(timeOne).isGreaterThan(timeTwo);
    return pullAndRunBuiltImage(targetImage);
  }
Builds with {@code jib:build} on a project at {@code projectRoot} pushing to {@code
imageReference} and run the image after pulling it.
jib-maven-plugin/src/integration-test/java/com/google/cloud/tools/jib/maven/BuildImageMojoIntegrationTest.java