TestAssertions
IntroductionThe script defining all the test assertions. Member Functions
assertSucceeds when the given expression is true. on assert( expr, message) Parameters
assertCocoaReferenceSucceeds when the given argument is a reference to a Cocoa object. Fails otherwise. on assertCocoaReference( anObject) Parameters
assertEqualSucceeds when the two given expressions have the same value. on assertEqual( expected, value) Parameters
assertEqualAbsErrorFails unless e1 and e2 are within delta from each other. on assertEqualAbsError( e1, e2, delta) ParametersDiscussionThis assertion succeeds if and only if |e1-e2| <= delta.
assertEqualRelErrorFails unless e1 and e2 have a relative error less than eps. on assertEqualRelError( e1, e2, eps) ParametersDiscussionThis assertion succeeds if and only if |e1-e2| <= min(|e1|,|e2|) * eps.
assertInheritsFromTests whether an object inherits from another object. on assertInheritsFrom( ancestor, descendant) ParametersDiscussionThis test walks up the inheritance chain of descendantObject until it finds obj, reaches the end of the inheritance chain, or detects a cycle in the inheritance chain.
assertInstanceOfTests whether the given expression belongs to the given class. on assertInstanceOf( klass, expr) Parameters
assertKindOfTests whether the given object or any of its ancestors belongs to the given class. on assertKindOf( klass, expr) ParametersDiscussionThis is mainly useful for user-defined scripts and user-defined inheritance hierarchies. For built-in types, it is almost equivalent to assertInstanceOf(). The main difference is that it can be used to test whether an expression is a number, but it does not matter if it is an integer or real (you cannot do that with assertInstanceOf()).
assertMissingA shortcut for assertEqual(missing value, expr). on assertMissing( expr) assertNilDeprecated. on assertNil( expr) See assertNotEqualSucceeds when the two given expressions are not equal. on assertNotEqual( unexpected, value) Parameters
assertNotReferenceFails when a variable is a reference. on assertNotReference( anObject) Parameters
assertNullA shortcut for assertEqual(null, expr). on assertNull( expr) assertReferenceTests whether a variable is a reference. on assertReference( anObject) Parameters
asTextUtility handler to coerce an object to on asText( s) failRaises a TEST_FAILED error. on fail( why) Parameters
failIfFails when the given assertion succeeds. on failIf( assertion, args, msg) ParametersDiscussionThis is mostly a convenience for testing ASUnit itself, since for every positive assertion (assert..., should...), ASUnit already defines a corresponding negative assertion (refute..., shouldnt...).
formatInheritanceChainHelper handler that returns a textual representation of an inheritance chain. on formatInheritanceChain( chain) isCocoaRefUtility handler to check whether a given expression is a reference to a Cocoa object. on isCocoaRef( x) DiscussionSee this MacScripter's thread. notOkSucceeds when its argument is false. on notOk( expr) Parameters
okSucceeds when its argument is true. on ok( expr) Parameters
ppReturns a textual representation of an object. on pp( anObject) ParametersrefuteSucceeds when the given expression is false. on refute( expr, message) Parameters
refuteCocoaReferenceSucceeds when the given argument is not a reference to a Cocoa object. Fails otherwise. on refuteCocoaReference( anObject) Parameters
refuteEqualA synonym for assertNotEqual(). on refuteEqual( unexpected, value) refuteInheritsFromSucceeds when anotherObj does not inherit (directly on indirectly) from obj. on refuteInheritsFrom( obj, anotherObj) Parameters
refuteInstanceOfSucceeds when the given expression is not of the given class. on refuteInstanceOf( klass, expr) Parameters
refuteKindOfVerifies that neither the given object nor any of its ancestors belong to the given class. on refuteKindOf( klass, expr) ParametersDiscussionSee assertKindOf().
refuteMissingA shortcut for refuteEqual(missing value, expr). on refuteMissing( expr) refuteNilDeprecated. on refuteNil( expr) See refuteNullA shortcut for refuteEqual(null, expr). on refuteNull( expr) shouldA synonym for assert(). on should( expr, message) shouldBeCocoaReferenceA synonym for assertCocoaReference(). on shouldBeCocoaReference( anObject) shouldBeReferenceA synonym for assertReference(). on shouldBeReference( anObject) shouldEqualA synonym for assertEqual(). on shouldEqual( expected, value) shouldNotBeCocoaReferenceA synonym for refuteCocoaReference(). on shouldNotBeCocoaReference( anObject) shouldNotBeReferenceA synonym for assertNotReference(). on shouldNotBeReference( anObject) shouldNotEqualA synonym for assertNotEqual(). on shouldNotEqual( unexpected, value) shouldNotRaiseFails if expectedErrorNumber is raised by executing object. on shouldNotRaise( expectedErrorNumber, object, message) Parameters
DiscussionFails if a certain error is raised.
shouldntA synonym for refute(). on shouldnt( expr, message) shouldntRaiseA synonym for shouldNotRaise(). Deprecated. on shouldntRaise( expectedErrorNumber, object, message) skipRaises a TEST_SKIPPED error. on skip( why) Parameters
Member Data
maxRecursionDepthThe maximum recursion depth for pp(). property maxRecursionDepth : 50 showInvisiblesDetermines whether invisible characters should be made visible. property showInvisibles : true DiscussionWhen this property is set to true (which is the default), invisible characters (spaces, tabulations, linefeeds, and returns) are printed as visible characters. This is especially useful when a test like assertEqual() fails because the expected value and the actual value differ, say, just because the actual value has a trailing new line that the expected value does not have. |