Jtest API

jtest
Class JT

java.lang.Object
  |
  +--jtest.JT

public class JT
extends java.lang.Object

General utility class to be used in Jtest test specifications.


Method Summary
static void addEvent(java.lang.String message)
          Adds an event with the string message to the "Test Case Input".
The only purpose for it is to be able to see when certain events happened while the test case was executing.
static void assert(boolean condition)
          Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.
static void assert(boolean condition, java.lang.String message)
          Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.
static void assert(java.lang.String message, boolean condition)
          Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.
protected static java.lang.Object makeStubObject(java.lang.Class cl)
          Creates a stub object for the class cl.
static void println(java.lang.String text)
          Equivalent to System.out.println (text).
It will always print the text to standard out, even when running automatic test cases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addEvent

public static void addEvent(java.lang.String message)
Adds an event with the string message to the "Test Case Input".
The only purpose for it is to be able to see when certain events happened while the test case was executing.
Parameters:
message - message that identifies the event.

assert

public static void assert(boolean condition)
Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.

assert

public static void assert(boolean condition,
                          java.lang.String message)
Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.
Parameters:
message - message to be used in the error reported.

assert

public static void assert(java.lang.String message,
                          boolean condition)
Asserts that condition is true.
If the condition is false then a "Specification Error" will be reported by Jtest.
Parameters:
message - message to be used in the error reported.

makeStubObject

protected static java.lang.Object makeStubObject(java.lang.Class cl)
Creates a stub object for the class cl. Stub objects are very useful when writting user defined stubs. A stub object is like any other object, with the following differences:

a) The stub object can be an instance of an interface. I.e. the following creates an instance of "Enumeration":
         Enumeration enum = makeStubObject (Enumeration.class);
 
b) Any method invocation or field reference is an stub even if no stub has been defined for it. If no stub has been defined for it a default stub returning the default initialization value for the method return type or field type is used (i.e. null for Object, 0.0d for double, ...).

Stub objects are necessary to be able to test classes that use interfaces for which an implementation has not been written yet. They can be used whenever an object of the interface class needs to be created. They can also be used whenever one wants to create an object of a given type without having to call any specific constructor (i.e. instead of using new java.io.FileInputStream ("what to put here?)", one can use: (FileInputStream) JT.makeStubObject (java.io.FileInputStream.class), this creates a FileInputStream object, but no constructor is called to initialize it.

println

public static void println(java.lang.String text)
Equivalent to System.out.println (text).
It will always print the text to standard out, even when running automatic test cases.

Jtest API