This document lists the software participants must have on their development systems to work through the hands-on exercises for the Practical Test-Driven Development for Scala courses (both the in-person version and the web-delivered version).
You can use your existing Scala development environment or set up a Linux instance using our provisioning script.
Using your existing Scala development environment
If you have a development environment you like to use to work with Scala, you can use it for the class. You can use any development tools you prefer. The current version of the class is based on Scala 2.12.0-M4. If you are using a different version, you may encounter some minor differences between the material presented in class and what you see in your development environment.
Using a virtual machine
If you don’t have a suitable Scala development environment, or you prefer to use a separate environment for the class, then you can configure a virtual machine with a suitable environment using this github project: http://github.com/neopragma/provision-ubuntu-16.04-scalatrain.
The script assumes you have created a virtual machine and installed Ubuntu Desktop 16.04 (64bit) on the virtual machine. You also have to install git on the virtual machine. Then you can clone the repository and run the setup script to configure the environment. It will install OpenJDK 8, Maven, and Eclipse Mars. If you prefer, you can provision a physical computer using the same script.
After the script has run, there are still a few things to set up manually.
Manual installation & configuration steps
Log out and log in again
The setup script modifies ~/.profile. The only way (well, the simplest way) to make the changes sticky (beyond the current shell) is to restart the session.
Ensure the starter application can build and run
The setup script installs Scala and Scalatest and copies a small example project to ~/workspace/starter. The purpose of the starter application is to verify the environment has been set up properly and it’s possible to run Scalatest and Scala. Open a Terminal window and navigate to that directory. Run the following command:
If Scala and Scalatest were installed correctly, then the starter application will build, its tests will run successfully, and it will run to display “hello” on the console. This will take some time, as sbt must download a number of dependencies.
Install JetBrains IntelliJ IDEA
The Ubuntu configuration for the course uses JetBrains IntelliJ IDEA, Community Edition, as the IDE for class projects.
IntelliJ IDEA Community Edition isn’t available in a form that can be downloaded with wget or curl or some such tool and then built or configured in an unattended way. It has to be downloaded manually and then configured semi-manually. This is the reason the setup script doesn’t install it for you.
- Visit https://www.jetbrains.com/idea/download/#section=linux and download “Community.”
- Uncompress the downloaded file:
tar xvzf idea*
- Move the expanded directory to /opt and change the directory name to idea:
sudo cp -r ~/Downloads/idea-blah-blah .
sudo mv idea-blah-blah idea
You can define an alias for idea if you prefer.
- Execute the script /opt/idea/bin/idea.sh. It will prompt you to agree with license terms and give you the opportunity to override defaults. Take all defaults until you get to the Download featured plugins dialog. Select “Scala” and press Install. Then resume answering the prompts until the script finishes.
Running a Scala application within IntelliJ IDEA
At the end of the installation script, it will ask you if you want to start IntelliJ IDEA. Start it to complete the configuration.
Import the starter project, choosing the option to use the configuration already defined in its files. To run it, you must edit run configurations, hit the “plus” button, from Defaults choose “SBT Task”, and give it a name. Running with that configuration will then be equivalent to running sbt from the project root directory on the command line.
You will need two run configurations for each project you develop during class:
At this point the following should be true:
- When you run the verify script it reports that the configuration is as expected (no software is missing, as far as the script can tell).
- In directory ~/workspace/starter, the command sbt test causes the starter application to build, run its tests (which pass), and display “hello” on the console. The run ends with a “success” message on the console.
- You defined a runtime configuration inside of IntelliJ IDEA of type SBT Task that specifies the test command for sbt. You imported the starter project. When you run the test task, the result is the same as when you run the application from the command line.
You’re ready to work.
If you have questions or difficulties configuring an environment for the class, please contact us at firstname.lastname@example.org.