CS2102 (B10): Object-Oriented Design Concepts
Instructions for Using the Testing Library


Home | Staff and Office Hours | Lectures and Assignments | MyWPI | Policies


We expect you to use a testing library that provides the check-expect behavior you saw in Racket. In lecture, we showed how to use check-expect in Java, but additional documentation may be useful for future reference. Instructions for using the testing library in each environment follow:


DrJava Users

  1. Download the tester library.
  2. Download Main.java to the same directory.
  3. When an assignment asks you to create a new project:
    1. Make a new folder to hold all the project files.
    2. Copy Main.java into the new folder.
    3. Under the "Project" menu, select "New". After you name the project, DrJava will bring up the "Project Properties" box.
      • If it isn't set, select the new folder you just created as Project Root.
      • Enter/select the "Main.java" file next to Main class.
      • Select "Add" in Extra Classpath, then select the tester.jar file you downloaded.
    New files will go into this project folder unless you change projects.

Experienced Eclipse Users

  1. Download the tester library.
  2. import tester.Tester into your Examples class
  3. In your Run Configurations, set tester.Main as your Main class

Eclipse Newbies

Step 1: set up your workspace and launch an Eclipse project

  1. Whereever you choose to keep your Java files, create two new folders called EclipseWorkspace and EclipseJars.

  2. Download the tester library and save it to your EclipseJars folder.

  3. Start Eclipse. If Eclipse prompts you for a workspace, browse to the EclipseWorkspace folder you created. If Eclipse doesn't prompt you for a workspace, then in the File menu, choose Switch workspace and browse to your EclipseWorkspace folder.

  4. Create a project: in the File menu select New then Java Project. Where it asks for Project Name type Project1 (you may select a different name, but we will refer to it as Project1 from now on). Make sure that "Use an execution environment JRE" and "Create separate folders for sources and class files" are selected, then select Next.

  5. In the Java Settings pane select the Libraries tab. On the right click on Add External JARs... You will get a chooser window. Navigate to your EclipseJars folder and select the tester jar file you downloaded. Hit Finish.

Step 2: Creating files

  1. In Eclipse, it is customary to keep each class definition and each interface in its own separate file. The convention is to name the file Classname.java, where Classname is the name of the class or interface that you're defining. In the File menu, choose New and then select either Class or Interface. Once you fill in the filename and click Finish, a pane will open with your class/interface name.

Step 3: Set up the run configuration and run the program

  1. Highlight Project1 in the Package Explorer pane. In the Run menu select Run Configurations.... In the top left corner of the inner pane click on the leftmost item. When you mouse over it should show "New launch configuration". (If this item isn't available, choose Java Application. The New launch configuration item should now be visible.) Select the name for this configuration - usually the same as the name of your project. Where it says Main class: click on Search.... and choose Main - tester. Click Apply and then Run to run your program.

    If you did everything correctly, you should see a message in the Console window that says something about "Tests for the class: Examples". The next time you want to run the same project, hit the green circle with the white triangle on the top left side of the main menu.