JsUnit 1.3
Project Developer Home doxygen

JsUnit.js File Reference


Detailed Description

Test unit classes for JavaScript.

This file contains a port of the JUnit Java package of Kent Beck and Erich Gamma for JavaScript.

If this file is loaded within a browser, an onLoad event handler is set. This event handler will set the global variable isJsUnitPageLoaded to true. Any previously set onLoad event handler is restored and called.


Classes

class  ComparisonFailure
 Thrown when a test assert comparing equal strings fail. More...
class  AllTestsCollector
 A collector for the AllTests class. More...
class  TestRunner
 TestRunner of JsUnit 1.1. More...
class  Protectable
 A protectable can be run and throw an Error. More...
class  XMLResultPrinter
 Convert the result of a TextTestPrinter into XML to be used by JUnitReport. More...
class  RepeatedTest
 A Decorator that runs a test repeatedly. More...
class  ResultPrinter
 Class to print the result of a TextTestRunner. More...
class  TextTestRunner
 Class for an application running test suites with a test based status report. More...
class  TestSuite
 A TestSuite is a composition of Tests. More...
class  TestListener
 A listener for test progress. More...
class  TestSetup
 A Decorator to set up and tear down additional fixture state. More...
class  TestDecorator
 A Decorator for Tests. More...
class  TestFailure
 A TestFailure collects a failed test together with the caught exception. More...
class  TestCase
 A test case defines the fixture to run multiple tests. More...
class  ClassicResultPrinter
 The ResultPrinter of JsUnit 1.1. More...
class  TestCollector
 A collector for Test classes. More...
class  TestRunListener
 A listener interface for observing the execution of a test run. More...
class  TestCaseCollector
 A TestCase collector for all test cases within a scope. More...
class  GenericTestCollector
 A generic collector for all Test classes within a scope. More...
class  Test
 A test can be run and collect its results. More...
class  BaseTestRunner
 General base class for an application running test suites. More...
class  TestSuiteCollector
 A TestSuite collector for all test suites within a scope. More...
class  ExceptionTestCase
 A TestCase that expects an exception of class mClass to be thrown. More...
class  Assert
 A set of assert methods. More...
class  EmbeddedTextTestRunner
 Class for an embeddable text-oriented TestRunner used in other applications with a status report. More...
class  HTMLTestRunner
 Class for an application running test suites reporting in HTML. More...
class  AssertionFailedError
 Thrown when a test assertion fails. More...

Functions

void Assert_assertNull (String msg, Object object)
 Asserts that an object is null.
Array GenericTestCollector_collectTests ()
 Collect the Test classes.
void XMLResultPrinter_addFailure (Test test, AssertionFailedError afe)
 Implementation of TestListener.
void ResultPrinter_printFooter (TestResult result)
 Print the footer of the test result.
void ResultPrinter_startTest (Test test)
 Implementation of TestListener.
String TestDecorator_getName ()
 Returns name of the test.
String TestFailure_trace ()
 Retrieve the stack trace.
void XMLResultPrinter_startTest (Test test)
 Implementation of TestListener.
void TestSuite_addTest (Test test)
 Add a test to the suite.
void ResultPrinter_printDefects (Array< TestFailure > array, String type)
 Print the defects of a special type of the test result.
Number TestCase_countTestCases ()
 Counts the number of test cases that will be run by this test.
TestResult TestCase_createResult ()
 Creates a default TestResult object.
void Assert_assertSame (String msg, Object expected, Object actual)
 Asserts that two values are the same.
void ClassicResultPrinter_printHeader (Test test)
 Write a header starting the application.
ResultPrinter TextTestRunner_getPrinter ()
 Retrieve the currently used ResultPrinter.
void TestDecorator_run (TestResult result)
 Run the test.
void ResultPrinter_print (TestResult result, Number runTime)
 Print the complete test result.
String BaseTestRunner_truncate (String str)
 Truncates string to maximum length.
Test TestCase_findTest (String testName)
 Find a test by name.
void XMLResultPrinter_endTest (Test test)
 Implementation of TestListener.
Boolean GenericTestCollector_isTest (Function testFunc)
 Test the function to be collected.
void ResultPrinter_printDefectTrace (void defect)
void Assert_assertUndefined (String msg, Object object)
 Asserts that an object is undefined.
TestResult TextTestRunner_doRun (Test test)
 Executes a test run with the given test.
void TestResult_endTest (Test test)
 A test ended.
void BaseTestRunner_addFailure (Test test, AssertionFailedError afe)
 Implementation of TestListener.
void TestResult_addListener (TestListener listener)
 Add a listener.
void TestResult_stop ()
 Marks that the test run should stop.
Number TestResult_runCount ()
 Retrieve the number of run tests.
void ResultPrinter_addError (Test test, Error except)
 Implementation of TestListener.
void ResultPrinter_printDefect (TestFailure defect, Number count)
 Print a defect of the test result.
Number HTMLTestRunner_setPrinter (Object outdev)
 Set printer.
void BaseTestRunner_startTest (Test test)
 Implementation of TestListener.
void RepeatedTest_run (TestResult result)
 Runs a test case with additional set up and tear down.
void ClassicResultPrinter_addFailure (Test test, Error except)
 An occurred failure was added.
void TestResult_removeListener (TestListener listener)
 Remove a listener.
void TestSuite_run (TestResult result)
 Runs the tests and collects their result in a TestResult instance.
void TextTestRunner_main (Array< String > args)
 Program entry point.
Object BaseTestRunner_getPreferences ()
 Retrieves the Object with the global preferences of any runner.
void TestRunner_run (String name, TestResult result)
 Runs all test of all suites and collects their results in a TestResult instance.
void TestResult_addError (Test test, Error except)
 Add an occurred error.
String TestSuite_getName ()
 Retrieves the name of the test suite.
Test TestSuite_testAt (Number index)
 Runs the test at the given index.
void TextTestRunner_setPrinter (Object outdev)
 Set printer.
void ClassicResultPrinter_print (TestResult result, Number runTime)
 Print the complete test result.
void ResultPrinter_printErrors (TestResult result)
 Print the errors of the test result.
void BaseTestRunner_addError (Test test, Error except)
 Implementation of TestListener.
void Assert_assertFloatEquals (String msg, Object expected, Object actual, Object tolerance)
 Asserts that two floating point values are equal to within a given tolerance.
Boolean BaseTestRunner_showStackRaw ()
 Retrieve the flag for raw stack output.
void ResultPrinter_printHeader (Number runTime)
 Print the header of the test result.
void TestResult_startTest (Test test)
 A test starts.
TestResult TextTestRunner_createTestResult ()
 Creates an instance of a TestResult to be used for the test run.
void TestRunner_addSuite (TestSuite suite)
 Add a test suite to the application.
void Assert_assertNotUndefined (String msg, Object object)
 Asserts that an object is not undefined.
void ClassicResultPrinter_writeLn (String str)
 Write a line of text.
void TestDecorator_setName (String name)
 Sets name of the test.
void ClassicResultPrinter_startTest (Test test)
 A test started.
String TestCase_toString ()
 Retrieve the test case as string.
Test TestDecorator_getTest ()
 Returns name the decorated test.
void TestSetup_run (TestResult result)
 Runs a test case with additional set up and tear down.
Test TestSuite_warning (String message)
 Returns a test which will fail and log a warning message.
Array AllTestsCollector_collectTests ()
 Collect Test class AllTests.
Number TestResult_failureCount ()
 Retrieve the number of occurred failures.
Boolean TestResult_wasSuccessful ()
 Returns whether the entire test was successful or not.
void Assert_assertEquals (String msg, Object expected, Object actual)
 Asserts that two values are equal.
Test TestSuite_findTest (String name)
 Search a test by name.
void TestRunner_runAll (TestResult result)
 Runs all test of all suites and collects their results in a TestResult instance.
void Assert_assertTrue (String msg, String cond)
 Asserts that a condition is true.
void ResultPrinter_setWriter (PrinterWriter writer)
 Sets the PrinterWriter.
void ResultPrinter_addFailure (Test test, AssertionFailedError afe)
 Implementation of TestListener.
void TestResult_run (Test test)
 Runs a test case.
void TestCase_runTest ()
 Override to run the test and assert its state.
String TestSuite_toString ()
 Retrieve the test suite as string.
String TestCase_getName ()
 Retrieves the name of the test.
Number TestResult_errorCount ()
 Retrieve the number of occurred errors.
void RepeatedTest_toString ()
void TestSuite_setName (String name)
 Sets the name of the suite.
void ResultPrinter_printDefectHeader (void defect, void count)
void TestCase_setName (String name)
 Sets the name of the test case.
void RepeatedTest_countTestCases ()
TestResult TextTestRunner_run (Object test)
 Runs a single test or a suite extracted from a TestCase subclass.
void Assert_assertNotNull (String msg, Object object)
 Asserts that an object is not null.
void XMLResultPrinter_addError (Test test, Error except)
 Implementation of TestListener.
Number TestDecorator_countTestCases ()
 Returns the number of the test cases.
Test TestDecorator_findTest (String name)
 Returns the test if it matches the name.
void ResultPrinter_endTest (Test test)
 Implementation of TestListener.
void ClassicResultPrinter_addError (Test test, Error except)
 An occurred error was added.
void ExceptionTestCase_runTest ()
 Execute the test method expecting that an exception of class mClass or one of its subclasses will be thrown.
void BaseTestRunner_endTest (Test test)
 Implementation of TestListener.
void TestResult_addFailure (Test test, AssertionFailedError afe)
 Add an occurred failure.
void BaseTestRunner_getTest (String name)
 Returns the Test corresponding to the given suite.
void TestResult_runProtected (Test test, Protectable p)
 Runs a test case protected.
TestResult EmbeddedTextTestRunner_run (Array< String > testNames, String suiteName)
 Executes the given tests in the array.
String ResultPrinter_elapsedTimeAsString (Number runTime)
 Returns the elapsed time in seconds as String.
void XMLResultPrinter_print (TestResult result, Number runTime)
 Print the complete test result as XML report to be used by JUnitReport.
void ClassicResultPrinter_endTest (Test test)
 A test ended.
Boolean TestFailure_isFailure ()
 Test for a JsUnit failure.
Array TestResult_cloneListeners ()
 Returns a copy of the listeners.
Error TestFailure_thrownException ()
 Retrieve the thrown exception.
Test TestFailure_failedTest ()
 Retrieve the failed test.
void BaseTestRunner_setPreference (String key, Object value)
 Set a global preference.
Boolean TestResult_shouldStop ()
 Checks whether the test run should stop.
void TestDecorator_basicRun (TestResult result)
 The basic run behavior.
void TestSuite_runTest (Test test, TestResult result)
 Runs a single test test and collect its result in a TestResult instance.
TestResult EmbeddedTextTestRunner_createTestResult ()
 Creates an instance of a TestResult to be used for the test run.
String TestDecorator_toString ()
 Returns the test as string.
Object BaseTestRunner_getPreference (String key, Object value)
 Retrieve the value of a global preference key.
void Assert_fail (String msg, CallStack stack, String usermsg)
 Fails a test with a give message.
void BaseTestRunner_setPreferences (Array prefs)
 Set any runner's global preferences.
Number TestRunner_countTestCases ()
 Counts the number of test cases that will be run by this test application.
void ResultPrinter_printFailures (TestResult result)
 Print the failures of the test result.
TestResult TextTestRunner_start (Object args)
 Starts a test run.
Number TestSuite_countTestCases ()
 Counts the number of test cases that will be run by this test suite.
Number TestSuite_testCount ()
 Returns the number of tests in this suite.
void ClassicResultPrinter_printFooter (TestResult result, Number runTime)
 Write a footer at application end with a summary of the tests.
String ComparisonFailure_toString ()
 Returns the error message.
void EmbeddedTextTestRunner_setPrinter (ResultPrinter printer)
 Set printer.
void TestResult ()
 A TestResult collects the results of executing a test case.
void Assert_assertFalse (String msg, String cond)
 Asserts that a condition is false.
void Assert_assertNotSame (String msg, Object expected, Object actual)
 Asserts that two values are not the same.
PrinterWriter ResultPrinter_getWriter ()
 Returns the associated writer to this instance.
String TestFailure_exceptionMessage ()
 Retrieve the exception message.
void TestSuite_addTestSuite (TestCase testCase)
 Add a test suite to the current suite.
void Assert_assertMatches (String msg, Object expected, Object actual)
 Asserts that a regular expression matches a string.
String TestFailure_toString ()
 Retrieve failure as string.
TestResult TestCase_run (TestResult result)
 Runs a test and collects its result in a TestResult instance.
Number TextTestRunner_runFailed (String msg)
 Run failed.
void TestCase_runBare ()


Function Documentation

Array AllTestsCollector_collectTests (  ) 

Collect Test class AllTests.

Returns:
Returns an Array with the class named AllTests.

void Assert_assertEquals ( String  msg,
Object  expected,
Object  actual 
)

Asserts that two values are equal.

Parameters:
msg An optional error message.
expected The expected value.
actual The actual value.
Exceptions:
AssertionFailedError Thrown if the expected value is not the actual one.

void Assert_assertFalse ( String  msg,
String  cond 
)

Asserts that a condition is false.

Parameters:
msg An optional error message.
cond The condition to evaluate.
Exceptions:
AssertionFailedError Thrown if the evaluation was not false.

void Assert_assertFloatEquals ( String  msg,
Object  expected,
Object  actual,
Object  tolerance 
)

Asserts that two floating point values are equal to within a given tolerance.

Parameters:
msg An optional error message.
expected The expected value.
actual The actual value.
tolerance The maximum difference allowed to make equality check pass.
Note:
This is an enhancement to JUnit 3.8
Exceptions:
AssertionFailedError Thrown if the expected value is not within the tolerance of the actual one.

void Assert_assertMatches ( String  msg,
Object  expected,
Object  actual 
)

Asserts that a regular expression matches a string.

Parameters:
msg An optional error message.
expected The regular expression.
actual The actual value.
Exceptions:
AssertionFailedError Thrown if the actual value does not match the regular expression.
Note:
This is an enhancement to JUnit 3.8
Since:
1.3

void Assert_assertNotNull ( String  msg,
Object  object 
)

Asserts that an object is not null.

Parameters:
msg An optional error message.
object The valid object.
Exceptions:
AssertionFailedError Thrown if the object is not null.

void Assert_assertNotSame ( String  msg,
Object  expected,
Object  actual 
)

Asserts that two values are not the same.

Parameters:
msg An optional error message.
expected The expected value.
actual The actual value.
Exceptions:
AssertionFailedError Thrown if the expected value is not the actual one.

void Assert_assertNotUndefined ( String  msg,
Object  object 
)

Asserts that an object is not undefined.

Parameters:
msg An optional error message.
object The defined object.
Exceptions:
AssertionFailedError Thrown if the object is undefined.

void Assert_assertNull ( String  msg,
Object  object 
)

Asserts that an object is null.

Parameters:
msg An optional error message.
object The null object.
Exceptions:
AssertionFailedError Thrown if the object is not null.

void Assert_assertSame ( String  msg,
Object  expected,
Object  actual 
)

Asserts that two values are the same.

Parameters:
msg An optional error message.
expected The expected value.
actual The actual value.
Exceptions:
AssertionFailedError Thrown if the expected value is not the actual one.

void Assert_assertTrue ( String  msg,
String  cond 
)

Asserts that a condition is true.

Parameters:
msg An optional error message.
cond The condition to evaluate.
Exceptions:
AssertionFailedError Thrown if the evaluation was not true.

void Assert_assertUndefined ( String  msg,
Object  object 
)

Asserts that an object is undefined.

Parameters:
msg An optional error message.
object The undefined object.
Exceptions:
AssertionFailedError Thrown if the object is not undefined.

void Assert_fail ( String  msg,
CallStack  stack,
String  usermsg 
)

Fails a test with a give message.

Parameters:
msg The error message.
stack The call stack of the error.
usermsg The message part of the user.
Exceptions:
AssertionFailedError Is always thrown.

void BaseTestRunner_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters:
test The test that had an error.
except The thrown error.

void BaseTestRunner_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters:
test The test that had a failure.
afe The thrown failure.

void BaseTestRunner_endTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The ended test.

Object BaseTestRunner_getPreference ( String  key,
Object  value 
)

Retrieve the value of a global preference key.

Parameters:
key The key of the preference.
value The default value.
Returns:
The value of the key or the default value.

Object BaseTestRunner_getPreferences (  ) 

Retrieves the Object with the global preferences of any runner.

Returns:
Returns the runner's global preferences.

void BaseTestRunner_getTest ( String  name  ) 

Returns the Test corresponding to the given suite.

Parameters:
name The name of the test. This is a template method, subclasses override runFailed(), clearStatus().

void BaseTestRunner_setPreference ( String  key,
Object  value 
)

Set a global preference.

Parameters:
key The key of the preference.
value The value of the preference.

void BaseTestRunner_setPreferences ( Array  prefs  ) 

Set any runner's global preferences.

Parameters:
prefs The new preferences.

Boolean BaseTestRunner_showStackRaw (  ) 

Retrieve the flag for raw stack output.

Returns:
Flag for an unfiltered stack output.

void BaseTestRunner_startTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The started test.

String BaseTestRunner_truncate ( String  str  ) 

Truncates string to maximum length.

Parameters:
str The string to truncate.
Returns:
The truncated string.

void ClassicResultPrinter_addError ( Test  test,
Error  except 
)

An occurred error was added.

Parameters:
test The failed test.
except The thrown exception.

void ClassicResultPrinter_addFailure ( Test  test,
Error  except 
)

An occurred failure was added.

Parameters:
test The failed test.
except The thrown exception.

void ClassicResultPrinter_endTest ( Test  test  ) 

A test ended.

Parameters:
test The ended test.

void ClassicResultPrinter_print ( TestResult  result,
Number  runTime 
)

Print the complete test result.

Parameters:
result The complete test result.
runTime The elapsed time in ms. Overloaded, because only the footer is needed.

void ClassicResultPrinter_printFooter ( TestResult  result,
Number  runTime 
)

Write a footer at application end with a summary of the tests.

Parameters:
result The result of the test run.
runTime The elapsed time in ms.

void ClassicResultPrinter_printHeader ( Test  test  ) 

Write a header starting the application.

Parameters:
test The top level test.

void ClassicResultPrinter_startTest ( Test  test  ) 

A test started.

Parameters:
test The started test.

void ClassicResultPrinter_writeLn ( String  str  ) 

Write a line of text.

Parameters:
str The text to print on the line. The method of this object does effectively nothing. It must be overloaded with a proper version, that knows how to print a line, if the script engine cannot be detected (yet).

String ComparisonFailure_toString (  ) 

Returns the error message.

Returns:
Returns the formatted error message. Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.

TestResult EmbeddedTextTestRunner_createTestResult (  ) 

Creates an instance of a TestResult to be used for the test run.

Returns:
Returns the new TestResult instance.

TestResult EmbeddedTextTestRunner_run ( Array< String testNames,
String  suiteName 
)

Executes the given tests in the array.

Parameters:
testNames The name of the tests to execute.
suiteName The name of the generated TestSuite (may be undefined).
Returns:
The result of the test.

void EmbeddedTextTestRunner_setPrinter ( ResultPrinter  printer  ) 

Set printer.

Parameters:
printer The ResultPrinter

void ExceptionTestCase_runTest (  ) 

Execute the test method expecting that an exception of class mClass or one of its subclasses will be thrown.

Array GenericTestCollector_collectTests (  ) 

Collect the Test classes.

Returns:
Returns an Array with the found Test classes.

Boolean GenericTestCollector_isTest ( Function  testFunc  ) 

Test the function to be collected.

The method tests the testFunc for the class type given in the constructor. A derived implementation may add additional criteria like the existence of a specific method of the class type.

Parameters:
testFunc The Function to be tested.
Returns:
Returns true if the function is a Test.

Number HTMLTestRunner_setPrinter ( Object  outdev  ) 

Set printer.

Parameters:
outdev Output device
Returns:
TextTestRunner.FAILURE_EXIT. The function wraps the PrinterWriter of the new ResultPrinter with a HTMLWriterFilter.
Deprecated:
since 1.2

void RepeatedTest_countTestCases (  ) 

void RepeatedTest_run ( TestResult  result  ) 

Runs a test case with additional set up and tear down.

Parameters:
result The result set.

void RepeatedTest_toString (  ) 

void ResultPrinter_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters:
test The test that had an error.
except The thrown error.

void ResultPrinter_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters:
test The test that had a failure.
afe The thrown failure.

String ResultPrinter_elapsedTimeAsString ( Number  runTime  ) 

Returns the elapsed time in seconds as String.

Parameters:
runTime The elapsed time in ms.

void ResultPrinter_endTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The test that ends.

PrinterWriter ResultPrinter_getWriter (  ) 

Returns the associated writer to this instance.

void ResultPrinter_print ( TestResult  result,
Number  runTime 
)

Print the complete test result.

Parameters:
result The complete test result.
runTime The elapsed time in ms.

void ResultPrinter_printDefect ( TestFailure  defect,
Number  count 
)

Print a defect of the test result.

Parameters:
defect The defect to print.
count The counter for this defect type.

void ResultPrinter_printDefectHeader ( void  defect,
void  count 
)

void ResultPrinter_printDefects ( Array< TestFailure array,
String  type 
)

Print the defects of a special type of the test result.

Parameters:
array The array with the defects.
type The type of the defects.

void ResultPrinter_printDefectTrace ( void  defect  ) 

void ResultPrinter_printErrors ( TestResult  result  ) 

Print the errors of the test result.

Parameters:
result The complete test result.

void ResultPrinter_printFailures ( TestResult  result  ) 

Print the failures of the test result.

Parameters:
result The complete test result.

void ResultPrinter_printFooter ( TestResult  result  ) 

Print the footer of the test result.

Parameters:
result The complete test result.

void ResultPrinter_printHeader ( Number  runTime  ) 

Print the header of the test result.

Parameters:
runTime The elapsed time in ms.

void ResultPrinter_setWriter ( PrinterWriter  writer  ) 

Sets the PrinterWriter.

Note:
This is an enhancement to JUnit 3.8
Parameters:
writer The writer for the report. Initialization of the ResultPrinter. If no writer is provided the instance uses the SystemWriter.

void ResultPrinter_startTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The test that starts.

Number TestCase_countTestCases (  ) 

Counts the number of test cases that will be run by this test.

Returns:
Returns 1.

TestResult TestCase_createResult (  ) 

Creates a default TestResult object.

Returns:
Returns the new object.

Test TestCase_findTest ( String  testName  ) 

Find a test by name.

Note:
This is an enhancement to JUnit 3.8
Parameters:
testName The name of the searched test.
Returns:
Returns this if the test's name matches or null.

String TestCase_getName (  ) 

Retrieves the name of the test.

Returns:
The name of test cases.

TestResult TestCase_run ( TestResult  result  ) 

Runs a test and collects its result in a TestResult instance.

The function can be called with or without argument. If no argument is given, the function will create a default result set and return it. Otherwise the return value can be omitted.

Parameters:
result The test result to fill.
Returns:
Returns the test result.

void TestCase_runBare (  ) 

void TestCase_runTest (  ) 

Override to run the test and assert its state.

void TestCase_setName ( String  name  ) 

Sets the name of the test case.

Parameters:
name The new name of test cases.

String TestCase_toString (  ) 

Retrieve the test case as string.

Returns:
Returns the name of the test case.

void TestDecorator_basicRun ( TestResult  result  ) 

The basic run behavior.

The function calls the run method of the decorated test.

Parameters:
result The test result.

Number TestDecorator_countTestCases (  ) 

Returns the number of the test cases.

Test TestDecorator_findTest ( String  name  ) 

Returns the test if it matches the name.

Parameters:
name The searched test name.

String TestDecorator_getName (  ) 

Returns name of the test.

Note:
This is an enhancement to JUnit 3.8

Test TestDecorator_getTest (  ) 

Returns name the decorated test.

Note:
This is an enhancement to JUnit 3.8

void TestDecorator_run ( TestResult  result  ) 

Run the test.

Parameters:
result The test result.

void TestDecorator_setName ( String  name  ) 

Sets name of the test.

Parameters:
name The new name of the test.

String TestDecorator_toString (  ) 

Returns the test as string.

Note:
This is an enhancement to JUnit 3.8

String TestFailure_exceptionMessage (  ) 

Retrieve the exception message.

Returns:
Returns the exception message.

Test TestFailure_failedTest (  ) 

Retrieve the failed test.

Returns:
Returns the failed test.

Boolean TestFailure_isFailure (  ) 

Test for a JsUnit failure.

Returns:
Returns true if the exception is a failure.

Error TestFailure_thrownException (  ) 

Retrieve the thrown exception.

Returns:
Returns the thrown exception.

String TestFailure_toString (  ) 

Retrieve failure as string.

Slightly enhanced message format compared to JsUnit 3.7.

Returns:
Returns the error message.

String TestFailure_trace (  ) 

Retrieve the stack trace.

Returns:
Returns stack trace (if available).

void TestResult (  ) 

A TestResult collects the results of executing a test case.

The test framework distinguishes between failures and errors. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like a JavaScript run-time error.

See also:
Test

void TestResult_addError ( Test  test,
Error  except 
)

Add an occurred error.

Add an occurred error and call the registered listeners.

Parameters:
test The failed test.
except The thrown error.

void TestResult_addFailure ( Test  test,
AssertionFailedError  afe 
)

Add an occurred failure.

Add an occurred failure and call the registered listeners.

Parameters:
test The failed test.
afe The thrown assertion failure.

void TestResult_addListener ( TestListener  listener  ) 

Add a listener.

Parameters:
listener The listener.

Array TestResult_cloneListeners (  ) 

Returns a copy of the listeners.

Returns:
A copy of the listeners.

void TestResult_endTest ( Test  test  ) 

A test ended.

A test ended, inform the listeners.

Parameters:
test The ended test.

Number TestResult_errorCount (  ) 

Retrieve the number of occurred errors.

Number TestResult_failureCount (  ) 

Retrieve the number of occurred failures.

void TestResult_removeListener ( TestListener  listener  ) 

Remove a listener.

Parameters:
listener The listener.

void TestResult_run ( Test  test  ) 

Runs a test case.

Parameters:
test The test case to run.

Number TestResult_runCount (  ) 

Retrieve the number of run tests.

void TestResult_runProtected ( Test  test,
Protectable  p 
)

Runs a test case protected.

Parameters:
test The test case to run.
p The protectable block running the test. To implement your own protected block that logs thrown exceptions, pass a Protectable to TestResult.runProtected().

Boolean TestResult_shouldStop (  ) 

Checks whether the test run should stop.

void TestResult_startTest ( Test  test  ) 

A test starts.

A test starts, inform the listeners.

Parameters:
test The test to start.

void TestResult_stop (  ) 

Marks that the test run should stop.

Boolean TestResult_wasSuccessful (  ) 

Returns whether the entire test was successful or not.

void TestRunner_addSuite ( TestSuite  suite  ) 

Add a test suite to the application.

Parameters:
suite The suite to add.

Number TestRunner_countTestCases (  ) 

Counts the number of test cases that will be run by this test application.

Returns:
The number of test cases.

void TestRunner_run ( String  name,
TestResult  result 
)

Runs all test of all suites and collects their results in a TestResult instance.

Parameters:
name The name of the test.
result The test result to fill.

void TestRunner_runAll ( TestResult  result  ) 

Runs all test of all suites and collects their results in a TestResult instance.

Parameters:
result The test result to fill.

void TestSetup_run ( TestResult  result  ) 

Runs a test case with additional set up and tear down.

Parameters:
result The result set.

void TestSuite_addTest ( Test  test  ) 

Add a test to the suite.

Parameters:
test The test to add. The test suite will add the given test to the suite and prepends the name of a TestCase with the name of the suite.

void TestSuite_addTestSuite ( TestCase  testCase  ) 

Add a test suite to the current suite.

All fixtures of the test case will be collected in a suite which will be added.

Parameters:
testCase The TestCase object to add.

Number TestSuite_countTestCases (  ) 

Counts the number of test cases that will be run by this test suite.

Returns:
The number of test cases.

Test TestSuite_findTest ( String  name  ) 

Search a test by name.

Note:
This is an enhancement to JUnit 3.8 The function compares the given name with the name of the test and returns its own instance if the name is equal.
Parameters:
name The name of the searched test.
Returns:
The instance itself or null.

String TestSuite_getName (  ) 

Retrieves the name of the test suite.

Returns:
The name of test suite.

void TestSuite_run ( TestResult  result  ) 

Runs the tests and collects their result in a TestResult instance.

Note:
As an enhancement to JUnit 3.8 the method calls also startTest and endTest of the TestResult.
Parameters:
result The test result to fill.

void TestSuite_runTest ( Test  test,
TestResult  result 
)

Runs a single test test and collect its result in a TestResult instance.

Parameters:
test The test to run.
result The test result to fill.

void TestSuite_setName ( String  name  ) 

Sets the name of the suite.

Parameters:
name The name to set.

Test TestSuite_testAt ( Number  index  ) 

Runs the test at the given index.

Parameters:
index The index.

Number TestSuite_testCount (  ) 

Returns the number of tests in this suite.

String TestSuite_toString (  ) 

Retrieve the test suite as string.

Returns:
Returns the name of the test case.

Test TestSuite_warning ( String  message  ) 

Returns a test which will fail and log a warning message.

Parameters:
message The warning message.

TestResult TextTestRunner_createTestResult (  ) 

Creates an instance of a TestResult to be used for the test run.

Returns:
Returns the new TestResult instance.

TestResult TextTestRunner_doRun ( Test  test  ) 

Executes a test run with the given test.

Parameters:
test The test.
Returns:
The result of the test.

ResultPrinter TextTestRunner_getPrinter (  ) 

Retrieve the currently used ResultPrinter.

Returns:
Returns the ResultPrinter.
Since:
1.3

void TextTestRunner_main ( Array< String args  ) 

Program entry point.

Parameters:
args Program arguments. The function will create a TextTestRunner or the TestRunner given by the preference "TestRunner" and run the tests given by the arguments. The function will exit the program with an error code indicating the type of success.

TestResult TextTestRunner_run ( Object  test  ) 

Runs a single test or a suite extracted from a TestCase subclass.

Parameters:
test The class to test or a test. This static method can be used to start a test run from your program.
Returns:
The result of the test.

Number TextTestRunner_runFailed ( String  msg  ) 

Run failed.

Parameters:
msg The failure message.
Returns:
TextTestRunner.FAILURE_EXIT.

void TextTestRunner_setPrinter ( Object  outdev  ) 

Set printer.

Parameters:
outdev Output device

TestResult TextTestRunner_start ( Object  args  ) 

Starts a test run.

Parameters:
args The (optional) arguments as Array or String
Exceptions:
Usage If an unknown option is used Analyzes the command line arguments and runs the given test suite. If no argument was given, the function tries to run AllTests.suite().

void XMLResultPrinter_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters:
test The test that had an error.
except The thrown error.

void XMLResultPrinter_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters:
test The test that had a failure.
afe The thrown failure.

void XMLResultPrinter_endTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The test that ends.

void XMLResultPrinter_print ( TestResult  result,
Number  runTime 
)

Print the complete test result as XML report to be used by JUnitReport.

Parameters:
result The complete test result.
runTime The elapsed time in ms.

void XMLResultPrinter_startTest ( Test  test  ) 

Implementation of TestListener.

Parameters:
test The test that starts.


JsUnit © 1999, 2000, 2001, 2002, 2003, 2006, 2007 by Jörg Schaible
Generated on Fri Oct 19 23:10:41 2007 for JsUnit by doxygen 1.5.2