org.baselinetest
Class TestCase

java.lang.Object
  extended by org.baselinetest.Assert
      extended by org.baselinetest.TestCase

public abstract class TestCase
extends Assert

A TestCase represents one of the TestCase classes that is used to comprise a TestSuite. It is made of one to many TestCaseSteps which each represent a single invocation of this TestCase.

Author:
jwan,jsnyder2

Constructor Summary
TestCase(TestSuite testSuite)
           
 
Method Summary
abstract  void cleanup()
          Cleanup the test case.
 void doAllWork()
           
abstract  void doWork()
          Run the test case.
 ArgumentCollection getArgumentCollection()
          Gets the ArgumentCollection of the current TestCaseStep during doWork(), otherwise the ArgumentCollection of the TestCase.
 ArgumentCollection getCaseArguments()
          Gets the ArgumentCollection for this TestCase.
 java.io.File getContextDir()
          Gets the directory for the context used to invoke this TestCase.
 TestCaseStep getCurrentTestCaseStep()
          Gets the currently running TestCaseStep during doWork().
 java.io.File getInheritedFile(java.lang.String fileName)
          Obtain a file with the given name.
 java.io.File getResultsDir()
          Gets the directory for the test results for the test suite.
 java.io.File getSuiteDir()
          Gets the directory for the TestSuite.
 int getTestCaseNumber()
           
 TestState getTestState()
          Gets the TestState for the current TestSuite.
 TestSuite getTestSuite()
          Gets the current TestSuite.
abstract  void init()
          Initialize the test case.
 void log(java.lang.String logText)
          Output a message to the execution logs.
 void log(java.lang.Throwable t)
          Output a throwable to the execution logs.
 void print(boolean b)
          Add to the baseline output.
 void print(int i)
          Add to the baseline output.
 void print(long l)
          Add to the baseline output.
 void print(java.lang.Object o)
          Add to the baseline output.
 void print(short s)
          Add to the baseline output.
 void println()
          Add a CR to the baseline output.
 void println(boolean b)
          Add to the baseline output.
 void println(int i)
          Add to the baseline output.
 void println(long l)
          Add to the baseline output.
 void println(java.lang.Object o)
          Add to the baseline output.
 void println(short s)
          Add to the baseline output.
 void printlnSubstitution(java.lang.String category, java.lang.Object o)
           
 void printSubstitution(java.lang.String category, java.lang.Object o)
          Print the substituted version of this object
 void run(TestResult testResult)
           
 void setTestCaseNumber(int testCaseNumber)
           
 
Methods inherited from class org.baselinetest.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestCase

public TestCase(TestSuite testSuite)
Method Detail

getCaseArguments

public ArgumentCollection getCaseArguments()
Gets the ArgumentCollection for this TestCase.

Returns:
the ArgumentCollection for this TestCase.
See Also:
getArgumentCollection()

getArgumentCollection

public ArgumentCollection getArgumentCollection()
Gets the ArgumentCollection of the current TestCaseStep during doWork(), otherwise the ArgumentCollection of the TestCase.

Returns:
the relevant ArgumentCollection.

getContextDir

public java.io.File getContextDir()
Gets the directory for the context used to invoke this TestCase.

Returns:
the context directory.

getResultsDir

public java.io.File getResultsDir()
Gets the directory for the test results for the test suite.

Returns:
the results directory.

getSuiteDir

public java.io.File getSuiteDir()
Gets the directory for the TestSuite.

Returns:
the suite directory.

getCurrentTestCaseStep

public TestCaseStep getCurrentTestCaseStep()
Gets the currently running TestCaseStep during doWork().

Returns:
the current TestCaseStep.

getTestState

public TestState getTestState()
Gets the TestState for the current TestSuite.

Returns:
the appropriate TestState.

getTestSuite

public TestSuite getTestSuite()
Gets the current TestSuite.

Returns:
the appropriate TestSuite.

getInheritedFile

public java.io.File getInheritedFile(java.lang.String fileName)
Obtain a file with the given name.

It will search for the given file in the following places: the results directory, the suite directory, and the context directory

Parameters:
fileName - the name of the file to return.
Returns:
a file with the given name, or null if one can not be found in any of the designated locations.

doWork

public abstract void doWork()
Run the test case.

This is where an implementation should place the actual testing code used to generate the baseline output. This will be executed after #init, and before #cleanup().


init

public abstract void init()
                   throws java.lang.Exception
Initialize the test case. This will be executed for all TestCases in the TestSuite, before running doWork().

Throws:
java.lang.Exception

cleanup

public abstract void cleanup()
                      throws java.lang.Exception
Cleanup the test case. This will be executed for all TestCases in the TestSuite, before running doWork().

Throws:
java.lang.Exception

doAllWork

public final void doAllWork()

run

public void run(TestResult testResult)

println

public void println()
Add a CR to the baseline output.


print

public void print(boolean b)
Add to the baseline output.

Parameters:
b - value to be printed to the baseline.

println

public void println(boolean b)
Add to the baseline output.

Parameters:
b - value to be printed to the baseline.

print

public void print(int i)
Add to the baseline output.

Parameters:
i - value to be printed to the baseline.

println

public void println(int i)
Add to the baseline output.

Parameters:
i - value to be printed to the baseline.

print

public void print(long l)
Add to the baseline output.

Parameters:
l - value to be printed to the baseline.

println

public void println(long l)
Add to the baseline output.

Parameters:
l - value to be printed to the baseline.

print

public void print(short s)
Add to the baseline output.

Parameters:
s - value to be printed to the baseline.

println

public void println(short s)
Add to the baseline output.

Parameters:
s - value to be printed to the baseline.

print

public void print(java.lang.Object o)
Add to the baseline output. If the object is null, the String "null" will be appended.

Parameters:
o - Object to be printed to the baseline.

printSubstitution

public void printSubstitution(java.lang.String category,
                              java.lang.Object o)
Print the substituted version of this object

Parameters:
category - substitution category to use for printing
o - object to lookup the substitution for

printlnSubstitution

public void printlnSubstitution(java.lang.String category,
                                java.lang.Object o)
Parameters:
category - substitution category to use for printing
o - object to lookup the substitution for

println

public void println(java.lang.Object o)
Add to the baseline output. If the object is null, the String "null" will be appended.

Parameters:
o - Object to be printed to the baseline.

log

public void log(java.lang.String logText)
Output a message to the execution logs.

Parameters:
logText - the text to be logged.

log

public void log(java.lang.Throwable t)
Output a throwable to the execution logs.

Parameters:
t - the throwable to be logged.

getTestCaseNumber

public int getTestCaseNumber()

setTestCaseNumber

public void setTestCaseNumber(int testCaseNumber)


Copyright © 2005-2009 Baseline Test. All Rights Reserved.