Skip to content

Setup For Labs

To be prepared for the labs, you'll need the following installed on your machine:

Once everything is installed, you can clone the repository to your machine and then run the tests and open it in IntelliJ IDEA.

A. Clone the Repository

  1. Change to your projects directory, or make one for this training class, e.g.:

    • Windows: mkdir C:\training and then cd \training
    • Mac: mkdir ~/training and then cd ~/training
  2. Clone the project repository from GitHub to your machine by doing:

    git clone https://github.com/spiral-learning/cvm.git
    
    • If you are still having trouble, download and unzip the project instead. You can do this by opening up a browser, and going to this URL:

      https://github.com/spiral-learning/cvm/archive/master.zip
      

B. Use Maven to Run the Test

Now use Maven from the command line to download the project dependencies and run the tests.

  1. Change to the directory holding the project:

    • Windows: cd \training\cvm
    • Mac: cd ~/training/cvm
  2. Run the test task in Maven by doing:

    mvn test
    
  3. Maven will download a bunch of files, so this could take a few minutes. Once it's finished downloading the files, it will compile the code and run the 1 (and only) test in the project. If all goes well, you should eventually see something like:

    Results :
    
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
    
    [INFO] ---------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ---------------------------------------------------------------------
    [INFO] Total time: 4.706 s
    [INFO] Finished at: 2017-09-11T10:39:51-07:00
    [INFO] Final Memory: 20M/437M
    [INFO] ---------------------------------------------------------------------
    

C. Open Project in IntelliJ IDEA

Now that all the dependencies have been downloaded and the project works, let's open it up in IDEA.

  1. Launch IntelliJ IDEA

  2. 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 the Open... to open the pom.xml (don't use Import) in the project directory.
  3. IDEA will then ask you how to open this file. Since we want it to be a new project, click Open as Project.

  4. The project will load and IDEA will do some indexing, which may take a few minutes.

D. Run the Test in IDEA

  1. Once the indexing completes, navigate to the CoffeeVendingMachineApplicationTest class -- Note: this is the test class, not the application class.

  2. Click on the green arrow next to the left of the class name

  3. The test results will show up in a bottom window pane and should be green, i.e., the single test passed.


You are done!