Skip to content

Commit 55e3862

Browse files
committed
A-TextUiTesting added ability to test using I/O redirection technique
1 parent 109de24 commit 55e3862

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed

src/main/java/Duke.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public static void main(String[] args) {
129129
}
130130

131131

132-
133132
} else {
134133
try {
135134
throw new UnknownInputException();

text-ui-test/EXPECTED.TXT

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
Hello from
2-
____ _
3-
| _ \ _ _| | _____
4-
| | | | | | | |/ / _ \
5-
| |_| | |_| | < __/
6-
|____/ \__,_|_|\_\___|
1+
Hello I'm Johnnythesnake
2+
What can I do for you?
3+
Enter a command: Got it. I've added this task:
4+
[T][ ] borrow book
5+
Now you have 1 tasks in the list.
6+
Enter a command: Here are the tasks in your list:
7+
1.[T][ ] borrow book
8+
Enter a command: Got it. I've added this deadline:
9+
[D][ ] project (by: 2023-08-31)
10+
Now you have 2 tasks in the list.
11+
Enter a command: Here are the tasks in your list:
12+
1.[T][ ] borrow book
13+
2.[D][ ] project (by: 2023-08-31)
14+
Enter a command: Got it. I've added this task:
15+
[E][ ] meeting (from: 2023-08-27 3pm to: 5pm)
16+
Now you have 3 tasks in the list.
17+
Enter a command: Here are the tasks in your list:
18+
1.[T][ ] borrow book
19+
2.[D][ ] project (by: 2023-08-31)
20+
3.[E][ ] meeting (from: 2023-08-27 3pm to: 5pm)
21+
Enter a command: OOPS!!! I'm sorry, but I don't know what that means :-(
22+
Enter a command: Bye. Hope to see you again soon!
23+
24+
25+
26+
727

text-ui-test/input.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
todo borrow book
2+
list
3+
deadline project /by 2023-08-31
4+
list
5+
event meeting /from 2023-08-27 3pm /to 5pm
6+
list
7+
unknown
8+
bye

text-ui-test/runtest.bat

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
@ECHO OFF
2-
32
REM create bin directory if it doesn't exist
43
if not exist ..\bin mkdir ..\bin
54

6-
REM delete output from previous run
7-
if exist ACTUAL.TXT del ACTUAL.TXT
5+
REM Set the path to the source code directory
6+
SET SRC_PATH=C:\Users\chang\Downloads\CS2103\ip\src\main\java
7+
8+
REM Set the path to the bin directory
9+
SET BIN_PATH=C:\Users\chang\Downloads\CS2103\ip\bin
810

9-
REM compile the code into the bin folder
10-
javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java
11+
REM Delete output from previous run
12+
DEL ACTUAL.TXT
13+
14+
REM Compile the code into the bin folder
15+
javac -cp %SRC_PATH% -Xlint:none -d %BIN_PATH% %SRC_PATH%\*.java
1116
IF ERRORLEVEL 1 (
12-
echo ********** BUILD FAILURE **********
13-
exit /b 1
17+
ECHO ********** BUILD FAILURE **********
18+
EXIT /B 1
1419
)
15-
REM no error here, errorlevel == 0
20+
REM No error here, errorlevel == 0
1621

17-
REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
18-
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
22+
REM Run the program, feed commands from input.txt file and redirect the output to ACTUAL.TXT
23+
java -classpath %BIN_PATH% Duke < input.txt > ACTUAL.TXT
1924

20-
REM compare the output to the expected output
25+
REM Compare the output to the expected output
2126
FC ACTUAL.TXT EXPECTED.TXT
27+

0 commit comments

Comments
 (0)