private BuildMojo setupMojo(final File pom) throws Exception {
    final MavenProject project = new ProjectStub(pom);
    final MavenSession session = newMavenSession(project);
    // for some reason the superclass method newMavenSession() does not copy properties from the
    // project model to the session. This is needed for the use of ExpressionEvaluator in BuildMojo.
    session.getRequest().setUserProperties(project.getModel().getProperties());

    final MojoExecution execution = newMojoExecution("build");
    final BuildMojo mojo = (BuildMojo) this.lookupConfiguredMojo(session, execution);
    mojo.buildDirectory = "target";
    // Because test poms are loaded from test/resources, tagInfoFile will default to
    // test/resources/target/image_info.json. Writing the json file to that location will fail
    // because target doesn't exist. So force it to use project's target directory.
    // But don't overwrite it if a test sets a non-default value.
    if (mojo.tagInfoFile.contains("src/test/resources")) {
      mojo.tagInfoFile = "target/image_info.json";
    }
    mojo.session = session;
    mojo.execution = execution;
    return mojo;
  }
Test what happens if tagInfoFile does not contain a path, i.e. the value is simply
"image_info.json".
src/test/java/com/spotify/docker/BuildMojoTest.java