Introduction

This Dojo (workshop) is about getting into the rhythm of writing tests, see them fail, write some code, see the test succeed and then refactor the code. Which is the Test Driven Development flow!

Setting up the Environment

This guide explains where to find Eclipse and which version to download. It shows which feature to install, that contains the 'Dojo Unit Testing Cases'.

WARNING: Use always a (new) clean Eclipse workspace, when importing a 'Unit Testing Case', as it will remove all projects from the workspace and import then the specific case.

Download Eclipse

http://www.eclipse.org/downloads/

In case you don't have any Eclipse yet, a good edition to get is 'Eclipse IDE for Java Developers'.

Tested on Eclipse version:

  • Eclipse 3.7 Indigo
  • Eclipse 3.8 (~Juno)
  • Eclipse 4.2 Juno

Get Eclipse Feature - Dojo Unit Testing Cases

Update Site: http://osadm.sourceforge.net/dojo/unittesting/eclipse-3.7-indigo/update-site

How to Add an Update Site

  Eclipse Menu: Help -> Install New Software…
  Window Available Software: Use the button 'Add...'
  Window Add Repository:
  - Use as Name 'Dojo Unit Testing'
  - Use as Location 'http://osadm.sourceforge.net/dojo/unittesting/eclipse-3.7-indigo/update-site/site.xml'
  - Close with button 'OK'
  Use the pull down bar 'Work with' and choose the just added entry 'Dojo Unit Testing'
  Wait a few seconds, till the feature structure had been downloaded. The central (white) window part will update and show the Name and Version of the found Features.
  Select the feature 'Dojo Unit Testing' version should be 1.0.3 or higher
  Use button 'Next >' to continue
  Window 'Install Details' is shown
  Use button 'Next >' to continue
  Window 'Review Licenses'
  Use the radio button 'I accept the termsof the license agreement'
  Use button 'Finish' to continue
  A window 'Security Warning' will pop up, as the feature is not signed
  Use button 'OK' to continue
  A window 'Software Updates' will pop up, asking you to restart Eclipse or just apply the changes
  Use button 'Restart Now' to continue

The Dojo Unit Testing Cases

The introduction about the cases can be found in Eclipse Help system. Use the Eclipse menu: Help -> Search This will open the view 'Help'. Use the link / tab 'Contents' to find the book 'Dojo Unit Testing'. Or in case you prefer to read the introduction in a browser, use the Eclipse menu: Help -> Help Contents This will open a browser, showing the same contents.

WARNING: Use always a (new) clean Eclipse workspace, when importing a 'Unit Testing Case', as it will remove all projects from the workspace and import then the specfic case.

After the feature 'Dojo Unit Testing Cases' is installed, there will be a extra view available.

  Make sure you are in the perspective 'Java':
    Eclipse Menu: Window -> Open Perspective -> Java
  Add the view 'Unit Testing' to your current perspective:
    Eclipse Menu: Windows -> Show View -> Other…
    From the tree select: Dojo -> Unit Testing
    Now a view 'Unit Testing' will be added somewhere.
    You can drag it now to any view accepting location (meaning NOT the editor area)
      Just try it out, in case you never done so
Figure: Eclipse selecting a view.

Adding a case to the workspace

WARNING: Last change to start with a clean workspace, otherwise it will be clean for you.

Double click one of the cases. In case your workspace is empty it will just install there. Otherwise in case there exist already a project with the name 'dojo-tdd' a window 'Warning' will pop up. Use the button 'Cancel' in case that project 'dojo-tdd' should NOT be over written. In case it can be overwritten, just use the button 'OK'. TIP: Project with other names are not touched. But the prefered way is to use an clean workspace, for working with these cases.

Overview Dojo Unit Testing

The figure below gives an impression of the Eclipse IDE after setting up the Dojo Feature. In this case there is already an Case loaded into the workspace, see the Package Explorer view on the left. Below the Package Explorer is the Unit Testing Cases view show. Here Case 2 - Degenerate Objects is bold, showing that is was loaded into the Eclipse workspace. In the middle, the Java editor is shown with some compilation issues. The Help contents is show on the right.

Figure: Overview of Eclipse with Dojo Unit Testing Cases and related Help.