Software Testing: Practical 2 Tutorial

This page gives a brief introduction to the basic tricks involved in practical 2. I can't reasonably cover all software configurations on all platforms, so here I demo using Eclipse 3.2, JUnit 3 and Coverlipse on DICE machines. Everyone has access to these, and I created the videos below on a DICE machine.

The videos were generated using pyvnc2swf-0.9.2, and the JavaScript player code is by Jesse Ruderman. Fantastic piece of software.

Getting Started

Video 1: Getting Started with Vmap under Eclipse

Obtaining Vmap and loading it into Eclipse is something you can do in several different ways. Here's one. Click on the video link above to start it playing (there's a short bit of doing nothing at the start, so give it a few seconds).

  1. First I create a directory for the Eclipse vmap project, retrieve the Vmap source from the web, and unpack the source into the project directory (in the video I start out in my home directory when I run “mkdir -p workspace/vmap”; the extra ~/ in the commands below means that they will work no matter what directory you start out in):
      > mkdir -p ~/workspace/vmap
      > wget http://www.inf.ed.ac.uk/teaching/courses/st/2007-8/resources/vmap-0.91.tar
      > tar -C ~/workspace/vmap -xf vmap-0.91.tar
    
  2. Then I run Eclipse 3.2 and create the new project from the build.xml.
  3. Finally I run vmap as a Java Application from the Eclipse GUI.

Creating a Test

Video 2: Writing a JUnit test of a Vmap class under Eclipse

Here I add the test stubs and implement a very simple test:

Implementation of testIsApplet():
public void testIsApplet() {
        Vmap v = new Vmap();
        assertFalse("isApplet not false!", v.isApplet());
}

Working on Coverage

Video 3: Working with Coverlipse to Improve Coverage

Here I show how to get coverage measurements and add a new test to improve coverage. The new test uses a couple of tricks:

Implementation of testOpenDocument():
public void testOpenDocument() throws Exception {
  String url = "http://www.w3.org";
  Vmap v = new Vmap();
  v.setProperty("default_browser_command_other_os", "firefox {0}");
  v.openDocument(new URL(url));
  System.out.println("Has your browser opened " + url + "? (y/n)");
  InputStreamReader converter = new InputStreamReader(System.in);
  BufferedReader in = new BufferedReader(converter);
  String response = in.readLine();
  assertTrue("openDocument(" + url + ") failed", response.equals("y"));
}


Home : Teaching : Courses : St : 2007-8 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh