582334 TDD-ohjelmointimenetelmä ja koodin suunnittelu (5 op), syksy 2009
582334 TDD programming technique and designing code (5 cr), autumn 2009

Kurssiesittely Luennot Harjoitukset

Exercise 4: Tetris #7 (mock objects). AddressBook #1 (first steps).

Tetris project work

See the instructions in the first exercise.

AddressBook project work

The goal of this project work is to make a graphical addressbook where contacts can be added (name, address, phone number, email) and the contacts can be searched based on all fields. The program is meant to be written from scratch. You may use this empty Maven project as a template.

The complete program will be something like shown below. The contacts in the addressbook are shown in an in-place editable table and when something is typed into the search field, the contact list is filtered on every key press so that the search results are shown in the list.

Example of the end result

Homework

max 7 points

  1. Tetris #7: Implement using TDD the removing of full rows and the counting of score. Continue your implementation from where you were left in the previous exercices. Use the EasyMock library in your tests, in order to learn interaction-based testing using mock objects. Also use the Mockito library in your tests; it is more a spy than a mock library and testing with it is more state-based. Because mock objects can not be used in many tests, implement those tests twise - once with EasyMock and once with Mockito.

    Mock objects can be used for example by implementing the removing of rows so that when a row is removed, the system will call a method on an interface which listens for the removal of rows. The interface could be something like this:

    public interface RowRemovalListener {
        void onRowsRemoved(int rowCount);
    }

    You will need to add the dependency to the EasyMock library into the Tetris project's pom.xml file, because it was not yet there at the beginning of this course. This can be done by adding the following rows into the file's <dependencies> block. You may have to regenerate your IDE's project files.

    <dependency>
        <groupId>org.easymock</groupId>
        <artifactId>easymock</artifactId>
        <version>2.5.2</version>
        <scope>test</scope>
    </dependency>

    1 point: Removing full rows has been implemented in Tetris using TDD. All tests pass.
    2 points: Removing full rows and counting the score has been implemented in Tetris using TDD. All tests pass.
    +1 extra point: The EasyMock library has been used in the tests.
    +1 extra point: The Mockito library has been used in the tests.

  2. AddressBook #1: Implement using TDD the adding of contacts and searching them. Do this alone, do not pair program, so that you could experience doing the first steps yourself. A graphical user interface is not yet supposed to be implemented (it will be done in later exercises).

    1 point: Implementing the addresbook using TDD has been started and at least three tests have been written. All tests pass.
    2 points: Adding contacts in the addressbook has been implemented using TDD. All tests pass.
    3 points: Adding contacts and searching them has been implemented using TDD. All tests pass.

In the exercise group we will discuss the start of a project using TDD, and pair program a graphical user interface for AddressBook.


Viimeksi muokattu 01.12.2010 21:04 Copyright © 2009 Esko Luontola