Prerequisites
-
JDK 9 or later
-
IntelliJ IDE
Importing the project into IntelliJ
-
Open IntelliJ (if you are not in the welcome screen, click
File
>Close Project
to close the existing project dialog first) -
Set up the correct JDK version
-
Click
Configure
>Project Defaults
>Project Structure
-
If JDK 9 is listed in the drop down, select it. If it is not, click
New…
and select the directory where you installed JDK 9 -
Click
OK
-
-
Click
Import Project
-
Locate the project directory and click
OK
-
Select
Create project from existing sources
and clickNext
-
Rename the project if you want. Click
Next
-
Ensure that your src folder is checked. Keep clicking
Next
-
Click
Finish
AddressBook saves data in a plain text file, one line for each person, in the format NAME p/PHONE e/EMAIL
.
Here is an example:
John Doe p/98765432 e/[email protected] Jane Doe p/12346758 e/[email protected]
All person data are loaded to memory at start up and written to the file after any command that mutates data.
In-memory data are held in a ArrayList<String[]>
where each String[]
object represents a person.
Windows
-
Open a DOS window in the
test
folder -
Run the
runtests.bat
script -
If the script reports that there is no difference between
actual.txt
andexpected.txt
, the test has passed
Mac/Unix/Linux
-
Open a terminal window in the
test
folder -
Run the
runtests.sh
script -
If the script reports that there is no difference between
actual.txt
andexpected.txt
, the test has passed
Troubleshooting test failures
-
Problem: How do I examine the exact differences between
actual.txt
andexpected.txt
?
Solution: You can use a diff/merge tool with a GUI e.g. WinMerge (on Windows). -
Problem: The two files look exactly the same, but the test script reports they are different.
Solution: This can happen because the line endings used by Windows is different from Unix-based OSes. Convert theactual.txt
to the format used by your OS using some utility. -
Problem: Test fails during the very first time.
Solution: The output of the very first test run could be slightly different because the program creates a new storage file. Tests should pass from the 2nd run onwards.