I created a method that uses a scanner object and then I want to create a test for that method. But soon as I run the test it just stops when it asks for your input to input into the console but i cant enter anything because it is a test method so how can I simulate a keyboard input in my tester method . Im inputting the values into a Hashmap
Main mehtod
public void addValue() {
System.out.println("Type the key value that you want to add");
Scanner keyb = new Scanner(System.in);
String key = keyb.next();
System.out.println("Type in the name Value");
String value = keyb.next();
mapExample.put(key, value);
}
Test method
void addValue() {
MapImplement mapTestO =new MapImplement();
mapTestO.addValue();
String mapValue=mapTestO.mapExample.get("KeyTest1");
assertEquals("ItemTest1",mapValue);
mapTestO=null;
}