Skip to content

Commit

Permalink
A-TextUiTesting added ability to test using I/O redirection technique
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertybox123 committed Aug 30, 2023
1 parent 109de24 commit 55e3862
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public static void main(String[] args) {
}



} else {
try {
throw new UnknownInputException();
Expand Down
32 changes: 26 additions & 6 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
Hello I'm Johnnythesnake
What can I do for you?
Enter a command: Got it. I've added this task:
[T][ ] borrow book
Now you have 1 tasks in the list.
Enter a command: Here are the tasks in your list:
1.[T][ ] borrow book
Enter a command: Got it. I've added this deadline:
[D][ ] project (by: 2023-08-31)
Now you have 2 tasks in the list.
Enter a command: Here are the tasks in your list:
1.[T][ ] borrow book
2.[D][ ] project (by: 2023-08-31)
Enter a command: Got it. I've added this task:
[E][ ] meeting (from: 2023-08-27 3pm to: 5pm)
Now you have 3 tasks in the list.
Enter a command: Here are the tasks in your list:
1.[T][ ] borrow book
2.[D][ ] project (by: 2023-08-31)
3.[E][ ] meeting (from: 2023-08-27 3pm to: 5pm)
Enter a command: OOPS!!! I'm sorry, but I don't know what that means :-(
Enter a command: Bye. Hope to see you again soon!





8 changes: 8 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
todo borrow book
list
deadline project /by 2023-08-31
list
event meeting /from 2023-08-27 3pm /to 5pm
list
unknown
bye
28 changes: 17 additions & 11 deletions text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
@ECHO OFF

REM create bin directory if it doesn't exist
if not exist ..\bin mkdir ..\bin

REM delete output from previous run
if exist ACTUAL.TXT del ACTUAL.TXT
REM Set the path to the source code directory
SET SRC_PATH=C:\Users\chang\Downloads\CS2103\ip\src\main\java

REM Set the path to the bin directory
SET BIN_PATH=C:\Users\chang\Downloads\CS2103\ip\bin

REM compile the code into the bin folder
javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java
REM Delete output from previous run
DEL ACTUAL.TXT

REM Compile the code into the bin folder
javac -cp %SRC_PATH% -Xlint:none -d %BIN_PATH% %SRC_PATH%\*.java
IF ERRORLEVEL 1 (
echo ********** BUILD FAILURE **********
exit /b 1
ECHO ********** BUILD FAILURE **********
EXIT /B 1
)
REM no error here, errorlevel == 0
REM No error here, errorlevel == 0

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

REM compare the output to the expected output
REM Compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT

0 comments on commit 55e3862

Please sign in to comment.