File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,11 +28,11 @@ test {
2828}
2929
3030application {
31- mainClass. set(" seedu.duke.Duke " )
31+ mainClass. set(" Milo.Milo " )
3232}
3333
3434shadowJar {
35- archiveBaseName = " duke "
35+ archiveBaseName = " Milo "
3636 archiveClassifier = null
3737}
3838
Original file line number Diff line number Diff line change 1+ package Milo ;
2+ import org .junit .jupiter .api .Test ;
3+ import java .io .ByteArrayInputStream ;
4+ import java .io .ByteArrayOutputStream ;
5+ import java .io .PrintStream ;
6+ import static org .junit .jupiter .api .Assertions .assertEquals ;
7+
8+ public class MiloTest {
9+ @ Test
10+ public void testGreetingAndExit () {
11+ ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream ();
12+ // Redirect System.out to capture printed output
13+ System .setOut (new PrintStream (outputStreamCaptor ));
14+ // Simulate user input with "bye" to immediately exit
15+ System .setIn (new ByteArrayInputStream ("bye\n " .getBytes ()));
16+ // Run the Milo application
17+ Milo milo = new Milo ();
18+ milo .run ();
19+
20+ String expectedOutput = """
21+ ____________________________________________________________
22+ Hello! I'm Milo.Milo
23+ What can I do for you?
24+ ╱|、
25+ (˚ˎ 。7 \s
26+ |、˜〵 \s
27+ じしˍ,)ノ
28+ ____________________________________________________________
29+ ____________________________________________________________
30+ Bye. Hope to see you again soon!
31+ ∧,,,∧
32+ ( ̳• · •̳)
33+ / づ♡
34+ ____________________________________________________________
35+ """ ;
36+
37+ // Verify that the greeting and exit messages were printed
38+ assertEquals (expectedOutput , outputStreamCaptor .toString ().replace ("\r " , "" ));
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ package Milo ;
2+ import org .junit .jupiter .api .Test ;
3+ import java .io .ByteArrayOutputStream ;
4+ import java .io .PrintStream ;
5+ import static org .junit .jupiter .api .Assertions .assertEquals ;
6+
7+ class UiTest {
8+ @ Test
9+ public void testGreetUser () {
10+ Ui ui = new Ui ();
11+ ui .greetUser ();
12+ ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream ();
13+ System .setOut (new PrintStream (outputStreamCaptor ));
14+ String expectedOutput = """
15+ ____________________________________________________________
16+ Hello! I'm Milo.Milo
17+ What can I do for you?
18+ ╱|、
19+ (˚ˎ 。7 \s
20+ |、˜〵 \s
21+ じしˍ,)ノ
22+ ____________________________________________________________
23+ """ ;
24+ assertEquals (expectedOutput , outputStreamCaptor .toString ());
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments