From 55e386244738eb306756c2b9e949443548b88747 Mon Sep 17 00:00:00 2001 From: Chang Ji-xuan Date: Wed, 30 Aug 2023 21:37:03 +0800 Subject: [PATCH] A-TextUiTesting added ability to test using I/O redirection technique --- src/main/java/Duke.java | 1 - text-ui-test/EXPECTED.TXT | 32 ++++++++++++++++++++++++++------ text-ui-test/input.txt | 8 ++++++++ text-ui-test/runtest.bat | 28 +++++++++++++++++----------- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java index 0934aab06c..d4e2b20fef 100644 --- a/src/main/java/Duke.java +++ b/src/main/java/Duke.java @@ -129,7 +129,6 @@ public static void main(String[] args) { } - } else { try { throw new UnknownInputException(); diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 657e74f6e7..f6034b4b34 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -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! + + + + diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb2..48bbb86a52 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -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 \ No newline at end of file diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat index 0873744649..c26afb09cf 100644 --- a/text-ui-test/runtest.bat +++ b/text-ui-test/runtest.bat @@ -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 +