JsUnit
Project Developer Home doxygen

Classes | Functions
JsUnit.js File Reference

Test unit classes for JavaScript. More...

Classes

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

Functions

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

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.

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
msgAn optional error message.
expectedThe expected value.
actualThe actual value.
Exceptions
AssertionFailedErrorThrown if the expected value is not the actual one.
void Assert_assertFalse ( String  msg,
String  cond 
)

Asserts that a condition is false.

Parameters
msgAn optional error message.
condThe condition to evaluate.
Exceptions
AssertionFailedErrorThrown 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
msgAn optional error message.
expectedThe expected value.
actualThe actual value.
toleranceThe maximum difference allowed to make equality check pass.
Note
This is an enhancement to JUnit 3.8
Exceptions
AssertionFailedErrorThrown 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
msgAn optional error message.
expectedThe regular expression.
actualThe actual value.
Exceptions
AssertionFailedErrorThrown 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
msgAn optional error message.
objectThe valid object.
Exceptions
AssertionFailedErrorThrown if the object is not null.
void Assert_assertNotSame ( String  msg,
Object  expected,
Object  actual 
)

Asserts that two values are not the same.

Parameters
msgAn optional error message.
expectedThe expected value.
actualThe actual value.
Exceptions
AssertionFailedErrorThrown if the expected value is not the actual one.
void Assert_assertNotUndefined ( String  msg,
Object  object 
)

Asserts that an object is not undefined.

Parameters
msgAn optional error message.
objectThe defined object.
Exceptions
AssertionFailedErrorThrown if the object is undefined.
void Assert_assertNull ( String  msg,
Object  object 
)

Asserts that an object is null.

Parameters
msgAn optional error message.
objectThe null object.
Exceptions
AssertionFailedErrorThrown if the object is not null.
void Assert_assertSame ( String  msg,
Object  expected,
Object  actual 
)

Asserts that two values are the same.

Parameters
msgAn optional error message.
expectedThe expected value.
actualThe actual value.
Exceptions
AssertionFailedErrorThrown if the expected value is not the actual one.
void Assert_assertTrue ( String  msg,
String  cond 
)

Asserts that a condition is true.

Parameters
msgAn optional error message.
condThe condition to evaluate.
Exceptions
AssertionFailedErrorThrown if the evaluation was not true.
void Assert_assertUndefined ( String  msg,
Object  object 
)

Asserts that an object is undefined.

Parameters
msgAn optional error message.
objectThe undefined object.
Exceptions
AssertionFailedErrorThrown if the object is not undefined.
void Assert_fail ( String  msg,
CallStack  stack,
String  usermsg 
)

Fails a test with a give message.

Parameters
msgThe error message.
stackThe call stack of the error.
usermsgThe message part of the user.
Exceptions
AssertionFailedErrorIs always thrown.
void BaseTestRunner_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters
testThe test that had an error.
exceptThe thrown error.
void BaseTestRunner_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters
testThe test that had a failure.
afeThe thrown failure.
void BaseTestRunner_endTest ( Test  test)

Implementation of TestListener.

Parameters
testThe ended test.
Object BaseTestRunner_getPreference ( String  key,
Object  value 
)

Retrieve the value of a global preference key.

Parameters
keyThe key of the preference.
valueThe 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
nameThe 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
keyThe key of the preference.
valueThe value of the preference.
void BaseTestRunner_setPreferences ( Array  prefs)

Set any runner's global preferences.

Parameters
prefsThe 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
testThe started test.
String BaseTestRunner_truncate ( String  str)

Truncates string to maximum length.

Parameters
strThe string to truncate.
Returns
The truncated string.
void ClassicResultPrinter_addError ( Test  test,
Error  except 
)

An occurred error was added.

Parameters
testThe failed test.
exceptThe thrown exception.
void ClassicResultPrinter_addFailure ( Test  test,
Error  except 
)

An occurred failure was added.

Parameters
testThe failed test.
exceptThe thrown exception.
void ClassicResultPrinter_endTest ( Test  test)

A test ended.

Parameters
testThe ended test.
void ClassicResultPrinter_print ( TestResult  result,
Number  runTime 
)

Print the complete test result.

Parameters
resultThe complete test result.
runTimeThe 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
resultThe result of the test run.
runTimeThe elapsed time in ms.
void ClassicResultPrinter_printHeader ( Test  test)

Write a header starting the application.

Parameters
testThe top level test.
void ClassicResultPrinter_startTest ( Test  test)

A test started.

Parameters
testThe started test.
void ClassicResultPrinter_writeLn ( String  str)

Write a line of text.

Parameters
strThe 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.

References TestResult().

TestResult EmbeddedTextTestRunner_run ( Array< String testNames,
String  suiteName 
)

Executes the given tests in the array.

Parameters
testNamesThe name of the tests to execute.
suiteNameThe name of the generated TestSuite (may be undefined).
Returns
The result of the test.

References TestResult().

void EmbeddedTextTestRunner_setPrinter ( ResultPrinter  printer)

Set printer.

Parameters
printerThe 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
testFuncThe Function to be tested.
Returns
Returns true if the function is a Test.
Number HTMLTestRunner_setPrinter ( Object  outdev)

Set printer.

Parameters
outdevOutput 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
resultThe result set.
void RepeatedTest_toString ( )
void ResultPrinter_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters
testThe test that had an error.
exceptThe thrown error.
void ResultPrinter_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters
testThe test that had a failure.
afeThe thrown failure.
String ResultPrinter_elapsedTimeAsString ( Number  runTime)

Returns the elapsed time in seconds as String.

Parameters
runTimeThe elapsed time in ms.
void ResultPrinter_endTest ( Test  test)

Implementation of TestListener.

Parameters
testThe 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
resultThe complete test result.
runTimeThe elapsed time in ms.
void ResultPrinter_printDefect ( TestFailure  defect,
Number  count 
)

Print a defect of the test result.

Parameters
defectThe defect to print.
countThe 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
arrayThe array with the defects.
typeThe type of the defects.
void ResultPrinter_printDefectTrace ( void  defect)
void ResultPrinter_printErrors ( TestResult  result)

Print the errors of the test result.

Parameters
resultThe complete test result.
void ResultPrinter_printFailures ( TestResult  result)

Print the failures of the test result.

Parameters
resultThe complete test result.
void ResultPrinter_printFooter ( TestResult  result)

Print the footer of the test result.

Parameters
resultThe complete test result.
void ResultPrinter_printHeader ( Number  runTime)

Print the header of the test result.

Parameters
runTimeThe elapsed time in ms.
void ResultPrinter_setWriter ( PrinterWriter  writer)

Sets the PrinterWriter.

Note
This is an enhancement to JUnit 3.8
Parameters
writerThe 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
testThe 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.

References TestResult().

Test TestCase_findTest ( String  testName)

Find a test by name.

Note
This is an enhancement to JUnit 3.8
Parameters
testNameThe 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
resultThe test result to fill.
Returns
Returns the test result.

References TestResult().

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
nameThe 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
resultThe 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
nameThe 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
resultThe test result.
void TestDecorator_setName ( String  name)

Sets name of the test.

Parameters
nameThe 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

Referenced by EmbeddedTextTestRunner_createTestResult(), EmbeddedTextTestRunner_run(), Test::run(), TestCase_createResult(), TestCase_run(), TextTestRunner_createTestResult(), TextTestRunner_doRun(), TextTestRunner_run(), and TextTestRunner_start().

void TestResult_addError ( Test  test,
Error  except 
)

Add an occurred error.

Add an occurred error and call the registered listeners.

Parameters
testThe failed test.
exceptThe thrown error.
void TestResult_addFailure ( Test  test,
AssertionFailedError  afe 
)

Add an occurred failure.

Add an occurred failure and call the registered listeners.

Parameters
testThe failed test.
afeThe thrown assertion failure.
void TestResult_addListener ( TestListener  listener)

Add a listener.

Parameters
listenerThe 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
testThe 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
listenerThe listener.
void TestResult_run ( Test  test)

Runs a test case.

Parameters
testThe 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
testThe test case to run.
pThe 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
testThe 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
suiteThe 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
nameThe name of the test.
resultThe test result to fill.
void TestRunner_runAll ( TestResult  result)

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

Parameters
resultThe test result to fill.
void TestSetup_run ( TestResult  result)

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

Parameters
resultThe result set.
void TestSuite_addTest ( Test  test)

Add a test to the suite.

Parameters
testThe 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
testCaseThe 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
nameThe 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
resultThe 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
testThe test to run.
resultThe test result to fill.
void TestSuite_setName ( String  name)

Sets the name of the suite.

Parameters
nameThe name to set.
Test TestSuite_testAt ( Number  index)

Runs the test at the given index.

Parameters
indexThe 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
messageThe warning message.
TestResult TextTestRunner_createTestResult ( )

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

Returns
Returns the new TestResult instance.

References TestResult().

TestResult TextTestRunner_doRun ( Test  test)

Executes a test run with the given test.

Parameters
testThe test.
Returns
The result of the test.

References TestResult().

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
argsProgram 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
testThe 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.

References TestResult().

Number TextTestRunner_runFailed ( String  msg)

Run failed.

Parameters
msgThe failure message.
Returns
TextTestRunner.FAILURE_EXIT.
void TextTestRunner_setPrinter ( Object  outdev)

Set printer.

Parameters
outdevOutput device
TestResult TextTestRunner_start ( Object  args)

Starts a test run.

Parameters
argsThe (optional) arguments as Array or String
Exceptions
UsageIf 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().

References TestResult().

void XMLResultPrinter_addError ( Test  test,
Error  except 
)

Implementation of TestListener.

Parameters
testThe test that had an error.
exceptThe thrown error.
void XMLResultPrinter_addFailure ( Test  test,
AssertionFailedError  afe 
)

Implementation of TestListener.

Parameters
testThe test that had a failure.
afeThe thrown failure.
void XMLResultPrinter_endTest ( Test  test)

Implementation of TestListener.

Parameters
testThe test that ends.
void XMLResultPrinter_print ( TestResult  result,
Number  runTime 
)

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

Parameters
resultThe complete test result.
runTimeThe elapsed time in ms.
void XMLResultPrinter_startTest ( Test  test)

Implementation of TestListener.

Parameters
testThe test that starts.

JsUnit © 1999, 2000, 2001, 2002, 2003, 2006, 2007 by Jörg Schaible
Generated on Wed Apr 15 2015 02:33:06 for JsUnit by doxygen 1.8.5