Im trying to test main program using junit where three input will be asked to enter.But my test is not receiving any output from the main method.Any help will be aprreciated
enter code here
@ Test
public void test_main_program() {
ByteArrayInputStream in=new ByteArrayInputStream("5\n6\n9\n".getBytes());
System.setIn(in);
ByteArrayOutputStream out=new ByteArrayOutputStream();
System.setOut(new PrintStream(out));
String consoleOutput="Enter side 1: \n";
consoleOutput+="Enter side 2: \n";
consoleOutput+="Enter side 3: \n";
consoleOutput+="This is a triangle.\n" ;
assertEquals(consoleOutput,out.toString());
}
Aucun commentaire:
Enregistrer un commentaire