首页 > 解决方案 > 如何设置临时 git-repo 进行测试?

问题描述

嗨,我想用单元测试在下面测试这个功能:

public String cloneRepo(String sshURL){
  System.out.println("Cloning repository "+ sshURL);
  String cloneStatus;

  try {
    Runtime.getRuntime().exec("git clone " + sshURL + " ./cloned-repo");
    cloneStatus = "Cloning OK";
  } catch (IOException e) {
    System.out.print("Could not clone repo.");
    cloneStatus = "Cloning Failed";
  }

  return cloneStatus;
}

我想创建一个临时的 git-repo 来测试它是否可能。因为如果您再次运行测试,测试将失败!由于克隆的存储库已经存在,是否可以在运行时创建一个临时的 Git-repo?

标签: javagit

解决方案


推荐阅读