Environment Setup
- Test-driven development
- Test Doubles
- Refactoring Legacy Code
- Training Activities
- Additional Concepts
Clone this wiki locally
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:
- example - a sandbox for ad hoc exercises
- greeting - a project for practicing the Greeting Kata
- unusual-spending - a project for practicing the Unusual Spending Kata (this vendor project supports it)
- example-cucumber - a sandbox for writing cucumber examples
- bank-ocr - a project for using Cucumber to practice the Bank OCR Kata
- selenium - a project for practicing writing JUnit and Cucumber tests with Selenium
- gilded-rose - a project for practicing the Gilded Rose Kata
- game-of-life - a project to work from for a Code Retreat
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:
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
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
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
:
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
:
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):
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"
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:
- Example - a sandbox for ad hoc exercises
- Greeting - a project for practicing the Greeting Kata
- UnusualSpending - a project for practicing the Unusual Spending Kata
- ExampleCucumber - a sandbox for writing cucumber examples
- BankOCR - a project for using Cucumber to practice the Bank OCR Kata
- Selenium - a project for practicing writing xUnit and Cucumber tests with Selenium
- GildedRose - a project for practicing the Gilded Rose Kata
- GameOfLife - a project to work from for a Code Retreat
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.
Verify ReSharper is installed by verifying a "ReSharper" item appears in the menu.
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:
This wiki was put together by your friends at test double. Come say hi!