Software Engineering Lecture: eXtreme programming
Extreme Programming (XP) is a software methodology for producing well managed high quality software that is responsive to the customers needs.  The software development is managed by planning small releases and constantly monitors the project's  completion date.  Managers communicate with the programmers via daily short stand up meetings, and behave more as coaches then as bosses.  High quality software is achieved by emphasizing simple design based on objected oriented (OO) principles, and using paired programming  to refractor, test and write code.  The final software product is responsive to the evolving customer needs by involving the customer in the development via user stories and acceptance tests.

XP is typically defined by a set of rules and practices.  I will list only the rules and practices that are important to our class (see http://www.extremeprogramming.org/rules.html for the complete list of rules):

Planning:

Designing:
The design rules are the most important for this class. Coding:
The second most important aspect. Testing:
Almost as important as designing.  A good design is worth nothing if it is implemented wrong. An example testing:
We want to design a unit test procedure that: My design for a test procedure is:
  1. For each proposed class method (I'll call functional method) write a test method.
  2. Test the syntax of the test method by compiling the test method.
  3. Call the test method from the class's main method.
  4. Code the the functional method.
  5. Check the syntax of functional method by compiling.
  6. Run main method of class.
  7. Repeat process with next functional method.
I code this example as spike in order to verify the above test procedure.  A spike is a quick program to test an idea:
public class ASpike{
    private String name;

    ASpike(String name){this.name = name;}

    public String toString() {return name;}

    // test method for constructor and string
    public static void testASpike(String testName){
        ASpike testASpike = new ASpike(testName);
        System.out.println("ASpike: testASpike: "+ testASpike);
    }

   public static void main(String[] args) {
        ASpike.testASpike("test");
   }
}  // end class ASpike


The procedure works!   The program prints out what we expect:

ASpike: testASpike: test
There is one problem; we would prefer a more silent tester.  We want a tester that only outputs if there is a failure, then we will not resist running the tester frequently.  Also we want to perform more then one test.  I wrote AnotherSpike to illustrate this technique.
public class AnotherSpike{
    private String name;

    AnotherSpike(String name){this.name = name;}

    public String toString() {return name;}

    // test method for constructor
    public static boolean AnotherSpikeTest(String testName){
        AnotherSpike testAnotherSpike = new AnotherSpike(testName);
        // Test for reference assignment
        if( testAnotherSpike == null ) {
            System.out.println("Failed: AnotherSpike: Constructor");
            return false;
        }
        return true;
    } // end test constructor

    // test method for toString
    public static boolean toStingTest(String testName){
        AnotherSpike testAnotherSpike = new AnotherSpike(testName);
        // Note we check for failure otherwise return true
        if( !( testName.equals(testAnotherSpike.toString()) ) ){
             System.out.println("Failed: AnotherSpike: toString");
             return false;
        }
        return true;
    }  // end test toString

 public static void main(String[] args) {
        // status of unit test keep in boolean pass
        boolean pass = true;

        // if test should fail pass becomes false and stays false
        pass = pass && AnotherSpike.AnotherSpikeTest("test");
        pass = pass && AnotherSpike.toStingTest("test");

        if( !pass ) System.out.println("FAILED: AnotherSpike FAILED unit tests");
        else System.out.println("PASSED: AnotherSpike PASSED unit tests");
    }
}  // end class AnotherSpike

Using this technique copious output will not be produced during tests.  All the unit tests will run and a failure will produce output.  Note that I have change the constructor test name; I am trying to develop a system metaphor.  Naming the test method is just the method name followed by Test.

Another example testing:  Maybe more to real life.
This example is only meant to illustrate how to write unit tests.  Please do not assume that your project should be designed with the following classes or methods.

For a project to construct a maze game assume that you have already written a Room class representing rooms in the maze and are currently coding the Player class which represents a player in the maze.  Naturally you well want a move() method for the Player class which attempts to moves a player through a door in room.  If the door is open the method returns the new room, and if the door is closed returns the old room.

So you write the test method we will call it moveTest().  The method belongs in the Player class and called from the main method.

public class Player{
   // class fields ....
   private String name;
   private Room location;

   // constructor ...
   Player(String name, Room location){
     this.name = name;
     this.location = location;
   } // end Player, too easy to test?

   // I recommend overload the toString method,
   // makes testing easier
   String toString(){
     // assumed that I have overload Room's toString
     return "Player "+name+" in Room "+location;
   }

   public boolean moveTest(){
      // Need to make some rooms with all the doors closed
      Room testRoom = new Room("testRoom");
      Room adjacentRoom = new Room("adjacentRoom");

     // Need to open the door between the two rooms,
     // assume that directions are public static final of Room
     testRoom.setDoorOpen(Room.EAST, adjacentRoom);
     adjacentRoom.setDoorOpen(Room.WEST, testRoom);

     // also need a player located in testRoom
     Player testPlayer = new Player("testPlayer", testRoom);

     // Test by moving the player
     if ( !(testPlayer.move(Room.EAST) == adjacentRoom) ){
        System.out.println("FAILED: moveTest open door from "
            +testRoom+" going EAST to "+adjacentRoom);
         return false;
     }
     if( !(testPlayer.move(Room.EAST) == adjacentRoom) ){
        System.out.println("FAILED: moveTest closed door from "
            +adjacentRoom+" going EAST ");
        return false;
     }
     // and test more moves ....

     // passed all test
     return true;
   } // end moveTest

   // more methods ...

   // we call moveTest from the main
   public static void main(String [] arg){
     boolean pass = true;

     pass = pass && Player.moveTest()
     // more tests go here

     if( !pass ) System.out.println("FAILED: Player FAILED unit tests");
     else System.out.println("PASSED: Player PASSED unit tests");

   } // end Player main

In your projects you should include test methods.