2010 FRC Java API


edu.wpi.first.testing
Class TestClass

java.lang.Object
  extended by edu.wpi.first.testing.TestClass

public abstract class TestClass
extends Object

This class should be extended by test classes. Make sure to call the constructor for each subclass once so that the class is added to the master hashtable

Author:
dtjones

Nested Class Summary
 class TestClass.Test
          This class should be extended within subclasses of each TestClass to add a test.
 
Constructor Summary
TestClass()
          Create a new instance of the test class and add it to the master table of test classes
 
Method Summary
protected  void assertEquals(double expected, double actual)
          Fail the test if the given items are not the same
protected  void assertEquals(double expected, double actual, double tolerance)
          Fail the test if the given items are not the same
protected  void assertEquals(long expected, long actual)
          Fail the test if the given items are not the same
protected  void assertEquals(Object expected, Object actual)
          Fail the test if the given items are not the same
protected  void assertFail(String msg)
          Fail the test.
protected  void assertFalse(boolean value)
          Fail the test if the given value is false.
protected  void assertTrue(boolean value)
          Fail the test if the given value is true.
static Failure[] getFailures()
          Get a list of all the failed tests.
abstract  String getName()
          Get the name of this TestClass.
static void run(String clas)
          Run the tests within the class name given
static void run(String clas, String test)
          Run the given test within the given class
static void runAll()
          Run all of the tests in all of the classes.
 void setup()
          Setup code to run before the tests within this class are run
 void teardown()
          Teardown code to run after the tests within this class are run
 String toString()
          Get a string representing this TestClass.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestClass

public TestClass()
Create a new instance of the test class and add it to the master table of test classes

Method Detail

getName

public abstract String getName()
Get the name of this TestClass. This should be unique within the testClasses

Returns:
The name of this test class

setup

public void setup()
Setup code to run before the tests within this class are run


teardown

public void teardown()
Teardown code to run after the tests within this class are run


getFailures

public static Failure[] getFailures()
Get a list of all the failed tests.

Returns:
A list of all of the failed tests.

toString

public String toString()
Get a string representing this TestClass.

Overrides:
toString in class Object
Returns:
The name of this test class.

run

public static void run(String clas)
Run the tests within the class name given

Parameters:
clas - The name of the TestClass to run

run

public static void run(String clas,
                       String test)
Run the given test within the given class

Parameters:
clas - The name of the class to run.
test - The name of the test to run.

runAll

public static void runAll()
Run all of the tests in all of the classes.


assertFail

protected void assertFail(String msg)
Fail the test.

Parameters:
msg - A message descibing the failure.

assertEquals

protected void assertEquals(Object expected,
                            Object actual)
Fail the test if the given items are not the same

Parameters:
expected - The expected value.
actual - The actual value.

assertEquals

protected void assertEquals(long expected,
                            long actual)
Fail the test if the given items are not the same

Parameters:
expected - The expected value.
actual - The actual value.

assertEquals

protected void assertEquals(double expected,
                            double actual)
Fail the test if the given items are not the same

Parameters:
expected - The expected value.
actual - The actual value.

assertEquals

protected void assertEquals(double expected,
                            double actual,
                            double tolerance)
Fail the test if the given items are not the same

Parameters:
expected - The expected value.
actual - The actual value.
tolerance - The amount by which the values must match

assertTrue

protected void assertTrue(boolean value)
Fail the test if the given value is true.

Parameters:
value - Boolean value that must be true for success

assertFalse

protected void assertFalse(boolean value)
Fail the test if the given value is false.

Parameters:
value - Boolean value that must be false for success

2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.