java - 如何设置临时 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?
解决方案
推荐阅读
- reactjs - 无状态组件 React 路由器
- azure - Azure 事件网格到 Azure 中继,混合连接
- node.js - Nodejs 和 Jimp 缩略图生成
- javascript - ajax返回成功后没有出现烤面包机
- angular - 测试效果抛出 NgRx
- visual-studio-code - 可以从 vscode 中删除 text-shadow 吗?
- mysql - Mysql 在多边形中查找点。
- javascript - 将 javascript $.get 响应推送到变量中
- jquery - 动画或过渡在溢出属性中不起作用
- php - 如何使用表格 + 按钮将数据发送到 php 页面