Setup For Labs¶
To be prepared for the labs, you'll need the following installed on your machine:
- Java 11 (or later)
- git 2.36 (or later)
- IntelliJ IDEA 2022.2.4 (or later) Community or Ultimate Editions
- or Eclipse (if you must)
Once everything is installed, you can clone the repository to your machine and then run the tests and open it in IntelliJ IDEA, or your preferred IDE.
A. Clone the Repository¶
The URL for the starter repository for this class will be provided via chat.
-
Change to your
projects
directory, or make one for this training class, e.g.:- Windows:
mkdir C:\training
and thencd \training
- Mac:
mkdir ~/training
and thencd ~/training
- Windows:
-
Clone the project repository from GitHub to your machine by doing:
git clone <name of code repository>.git
B. Use Maven to Run the Tests¶
Now use Maven from the command-line or terminal to download the project dependencies and run the tests. If you are unable to get this to work with the information below, you can skip to (C) and load the project in IntelliJ IDEA.
-
Change to the directory holding the project
-
Run the
verify
task in Maven by doing this from the command-line/terminal:macOS/Linux:¶
./mvnw verify
Windows¶
mvnw verify
Warning
If you see an error like:
Fatal error compiling: invalid flag: --release
Ensure that you have Java 11 or later working from your command-line. Java 8 doesn't understand the
--release
flag used by later releases.Warning
If you see a "security" error, you may need to temporarily rename the
settings.xml
file found in the.m2
directory under your home directory (e.g.,~/.m2
on Mac). Renamed it tosettings.xml.bak
, run Maven don't rename it back until you've loaded it into your IDE. -
Maven will download a number of files, so this could take a few minutes. Once it's finished downloading the files, it will compile the code and run all of the tests in the project. If all goes well, you should eventually see something like:
[INFO] Results: [INFO] [INFO] Tests run: 21, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.706 s [INFO] Finished at: 2020-09-11T10:39:51-07:00 [INFO] Final Memory: 20M/437M [INFO] ---------------------------------------------------------------------
C. Open Project in IntelliJ IDEA¶
These instructions are for IntelliJ, if you're using another IDE, open the project via the Maven
pom.xml
file as appropriate.
Now that all the dependencies have been downloaded, and the project works, let's open it up in IDEA.
-
Launch IntelliJ IDEA
-
Open the
pom.xml
file by doing the following:- If you see the Welcome screen, choose
Open
(not Import)
Otherwise...
- From the
File
menu, choose theOpen...
to open thepom.xml
(don't use Import) in the project directory.
- If you see the Welcome screen, choose
-
IDEA will then ask you how to open this file. Since we want it to be a new project, click
Open as Project
. -
The project will load and IDEA will do some indexing, which may take a few minutes.
D. Run the Tests in IDEA¶
-
Once the indexing completes, open the Project window and right-click on the
src > test > java
directory and select Run All Tests. -
The test results will show up in a bottom window pane and should be green, i.e., all the tests passed.