Skip to content

Environment Setup

Justin Searls edited this page Jul 29, 2016 · 2 revisions

Attendees of this course may use either Java & Eclipse or C# & Visual Studio. Depending on the language you want to use, the tools you'll want to install will vary.

Java

Source code

There is a preconfigured project that we will work from. Download it and verify everything works on your machine by following the instructions in its README files:

Once you've imported and installed the top-level project, you'll see that it defines a number of child projects that we'll work from over the course of the week:

IDE Plugins

There are a couple IDE plugins that we will use to reduce the amount of friction when running tests inside Eclipse.

All three of these plugins can be installed via the Eclipse marketplace, their own update sites, or manually. If a plugin's update site is inaccessible, download the source and manually install the plugin by placing the expanded plugin into the dropins folder in your Eclipse installation directory and then restarting Eclipse.

Verify MoreUnit is installed by right-clicking anywhere in a Java source listing and verifying a "MoreUnit" item appears in the context menu.

Verify EclEmma is installed by right-clicking a JUnit test and seeing a "Coverage As…" item in the context menu.

Verify Natural is installed by opening a Cucumber feature file (example: bank-ocr/src/test/resources/bank/bank-ocr.feature) and verify that syntax highlighting is enabled like so:

screen shot 2016-07-27 at 11 00 20 am

IDE Settings

New test templates

To reduce the friction when creating a new unit test, consider configuring these new test templates as code snippets to be activated using Eclipse auto-completion.

Download source & docs

By default, Eclipse will only fetch compiled dependencies, but not the source attachments or JavaDoc. Doing so adds little overhead and allows you to navigate to and read the code you depend on with a simple ctrl-click. Just visit Preferences -> Maven and checking Download Artifact Sources and Download Artifact JavaDoc

screen shot 2016-07-27 at 9 57 14 am

Wildcard static imports

In order to clear warnings, it's common to use the "Organize imports" command (ctrl-shift-o), but it has the side effect of creating an explicit import statement for every static import, clearing out any wildcards. This has the side effect of making DSL libraries like Hamcrest harder to use.

To change the behavior of organize imports to wildcard static imports more aggressively, visit Java -> Code Style -> Organize Imports and change "Number of static imports needed for .*" to 1

screen shot 2016-07-27 at 10 00 51 am

Organize packages hierarchically

When creating a lot of classes, it's easier to organize them into well-considered package hierarchies, but by default Eclipse will list them all out in a flat view that makes it harder to navigate. To display them hierarchically, click the Project Explorer pane's downward-facing triangle, and selecting Package Presentation -> Hierarchical:

screen shot 2016-07-27 at 10 02 47 am

Organize projects hierarchically

When working on a multi-project Maven module or a working set, you can group those projects together in Eclipse's Project Explorer by clicking the downward-facing triangle, and selecting Projects Presentation -> Hierarchical:

screen shot 2016-07-27 at 9 55 10 am

Autosave

When juggling a lot of files, switching tabs after forgetting to manually save can cause needless disruption to one's workflow—debugging only to realize the root cause was that a file wasn't saved can be really frustrating!

To configure Eclipse (4.6 & later) to autosave dirty editors, visit Preferences -> General -> Editors -> Autosave and enable autosave for dirty editors. Unless you have a slow build and "build automatically" enabled, reduce the default 20 second timer to something shorter (I have mine set to 1 second here):

screen shot 2016-07-27 at 10 13 47 am

Auto-format

To reduce whitespace commits, it can be helpful to auto-format & auto-organize imports on stage. To set it up, visit Preferences -> Java -> Editors -> Save Actions and tick "Perform the selected actions on save", along with "Format source code" and "Organize imports"

screen shot 2016-07-28 at 11 05 35 am

C#

Source code

There is preconfigured project that we will work from. Pull it down and verify it works on your machine by following the instructions in their README files:

Once you've opened the top-level solution, you'll see that it defines a number of child projects that we'll work from over the course of the week:

IDE

This setup assumes you're using Visual Studio 2015. Setup for earlier versions may vary.

Visual Studio Plugins

We will use the ReSharper plugin to reduce the amount of friction when running tests inside Visual Studio:

ReSharper can be installed via the Visual Studio Extensions and Updates manager, or the ReSharper download site.

screen shot 2016-07-28 at 11 58 00 am

Verify ReSharper is installed by verifying a "ReSharper" item appears in the menu.

screen shot 2016-07-28 at 12 00 00 pm

Verify the ReSharper test runner is enabled by opening a test class (example: Example/Example.Test/FeedsWalrusTest.cs) and verifying the circular "click to run" icon appears on the left side:

screen shot 2016-07-28 at 12 05 00 pm
You can’t perform that action at this time.