· Home

 · Download

 · Internals

 · Howto

 · People

 · Javadoc

 · Mailing List

A Simple JUnit Test

Here is a simple test case. The Player class is imported to play the script. It takes a script filename as its constructor argument (make sure you run the test from the correct directory). The play() method returns the test object instance that was used to play the script. You should use it for your tests.

import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;

import com.mtp.pounder.Player;

import my.package.MyComponent;

public class TestSomething extends TestCase {

  public TestSomething(String name) {
    super(name);
  }

  public static Test suite() {
    return new TestSuite(TestSomething.class);
  }

  /** Test something. **/
  public void testThatFeature() throws Exception {
    Player player = new Player("scripts/myScript.pnd");
    MyComponent mc = (MyComponent)player.play();

    assertEquals(1, mc.someMethod());
  }

}




Many thanks to SourceForge for hosting this project.
SourceForge



Copyright 2002 Matthew Pekar  All rights reserved.