First of all, I would like to apologize for my language skills, but my mother tongue is not English.
I have a small source code:
public void hello(List l){ switch (l.get(0) { case "hello": System.out.println("Hello!"); case "world": System.out.println("World"); break; } }
And I have to write a unit test that can test this code. But my skill is not enough. Can someone help me please? An example or a book or something else. I do not know how I can start it!
I value.
thank
, , , "". , - . , , , .
: , .
, JVM , , , ...
, . , String, -, , .
, , System.out. , System.out , , . , .
, System.out . PrintStream, , , PrintStream, .
, ( Mockito).
PrintStream mockStream = Mockito.mock(PrintStream.class); PrintStream original = System.out; System.out = mockStream; //call your method here: hello(myList); //check if your method has done its job correctly Mockito.verify(mockStream).println("Hello!"); //clean up System.out = orig;
, break , .
break