如何为以下方法使用junit5创建测试方法?
public static String readFromDBOrFile() {
String fileOrDB;
do {
Scanner scanner = new Scanner(System.in);
System.out.print("Select between reading from 'file' or 'DB': ");
String line = scanner.nextLine().toUpperCase().trim();
fileOrDB = !line.equals("FILE") && !line.equals("DB") ? null : line;
if(fileOrDB == null) System.out.println("Not a valid choice. Try again");
} while(fileOrDB == null);
System.out.println("Reading from : '" + fileOrDB + "'");
return fileOrDB;
}
对于JUnit 4使用https://stefanbirkner.github.io/system-rules/或对于JUnit 5使用https://github.com/stefanbirkner/system-lambda。>>