Jetif v1.8.0

jetif
Class TestCase

java.lang.Object
  extended byjetif.TestCase

public abstract class TestCase
extends Object

A TestCase class is a collection of test methods. All test logic are implemented in a TestCase class. This base class provides the way to access the test comments, define common procedure of each test case.

Version:
1.1
Author:
Vicky Wang

Constructor Summary
TestCase()
           
 
Method Summary
protected static void abort(String msg)
          Abort current test case with given message.
 void addComment(String comment)
          Add comment for this case result.
protected static void assertTrue(boolean condition)
          Assert the condition should be a true value.
protected static void assertTrue(String msg, boolean condition)
          Assert the condition should be a true value.
protected  void cleanup(boolean flag)
          Perform cleanup for each test case.
 void clearComments()
          Clear all comments of this case result.
protected static void fail(String msg)
          Fails a test with the given message.
protected  Class getTestClass()
          Returns the target test class for testing.
protected  Object getTestObject()
          Returns the target test object for testing.
 void removeComment(String comment)
          Remove a comment from this case result.
protected  boolean setup()
          Perform setup for each test case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestCase

public TestCase()
Method Detail

getTestClass

protected Class getTestClass()
                      throws FrameworkException
Returns the target test class for testing. The framework will use this class object to search the test method.

Returns:
a class object.
Throws:
FrameworkException - if error occurs.

getTestObject

protected Object getTestObject()
                        throws FrameworkException
Returns the target test object for testing. The framework will use this object as the instance to run test method. This method may returns null only if all test method are static method.

Returns:
the test object.
Throws:
FrameworkException - if error occurs.

setup

protected boolean setup()
Perform setup for each test case. This method will be called before each test case run, allows the developer implements common setup procedure for each test case.

Returns:
false means the setup failed, and the test method of current test case won't be ran.

cleanup

protected void cleanup(boolean flag)
Perform cleanup for each test case. This method will be called after each test case ran, allows the developer implements common cleanup procedure for each test case.

Parameters:
flag - the value returned by setup() method.

assertTrue

protected static void assertTrue(boolean condition)
Assert the condition should be a true value. Current test method will be failed if the condition if false.

Parameters:
condition - the condition to be tested.

assertTrue

protected static void assertTrue(String msg,
                                 boolean condition)
Assert the condition should be a true value. Current test method will be failed if the condition if false.

Parameters:
msg - message about this assertion.
condition - the condition to be tested.

abort

protected static void abort(String msg)
Abort current test case with given message. The test case will be marked as skipped if the user call this method to abort the test case.

Parameters:
msg - the message to explain the reason to abort the test case.

fail

protected static void fail(String msg)
Fails a test with the given message.


addComment

public void addComment(String comment)
Add comment for this case result.

Parameters:
comment - the comment message

removeComment

public void removeComment(String comment)
Remove a comment from this case result.

Parameters:
comment - the comment message.

clearComments

public void clearComments()
Clear all comments of this case result.


Jetif v1.8.0

Copyright © 2004,2005 Vicky Wang - All Rights Reserved.