Piszę w celu nauki projekt- liste todo , na razie konsolowo. jak napisać testy jednostkowe, pojaśni ktoś np na metodzie addTasks, jak sprawdzić dobrze tą metodę? rozumiem, że można sprawdzić np przekazac null, przekazac np wartosc 3 ale jak napisać taka metode testujaca. pisze w junit
public class Todo {
static Scanner sc = new Scanner(System.in);
ArrayList<String> tasks = new ArrayList<String>();
ArrayList<String> products = new ArrayList<String>();
void addTasks(){
System.out.println("Input a count of task");
int number = sc.nextInt();
for(int i = 0; i < number; i++ ){
System.out.println("Input task to todo lists");
tasks.add(sc.next());
System.out.print(tasks);
}
}
void removeTask(){
System.out.println("Input a count tasks to remove");
int numOfTask = sc.nextInt();
for(int i = 0; i < numOfTask; i++){
System.out.println("Input task to remove");
tasks.remove(sc.next());
System.out.print(tasks);
}
}
void editTask(){
System.out.println("Input a count tasks to edit");
int numEdit = sc.nextInt();
for(int i = 0; i < numEdit; i++){
System.out.println("Input number task to edit");
int task = sc.nextInt();
System.out.println("input new task");
String newTask = sc.next();
tasks.set(task, newTask);
System.out.print(tasks);
}
}
public static void main(String[] args) {
Todo td = new Todo();
td.addTasks();
td.removeTask();
td.editTask();
}
}