JSUnit
(jsunit)
Overview
The JSUnitAssertFunctions
class provides a comprehensive set of assertion methods for unit testing in Servoy. It supports operations such as equality checks, regular expression matching, null checks, and conditional assertions. These methods enable the validation of test outcomes with detailed messages and tolerances for specific scenarios like floating-point comparisons. Assertions can evaluate conditions as true or false, verify object definitions, or ensure two values are the same or different. Additional functions allow forcing test failures and checking against expected exceptions.
Methods Summarized
void
Asserts that two values are equal.
void
Asserts that two values are equal.
void
Asserts that a condition is false.
void
Asserts that a condition is false.
void
Asserts that two floating point values are equal to within a given tolerance.
void
Asserts that two floating point values are equal to within a given tolerance.
void
Asserts that a regular expression matches a string.
void
Asserts that a regular expression matches a string.
void
Asserts that an object is not null.
void
Asserts that an object is not null.
void
Asserts that two values are not the same.
void
Asserts that two values are not the same.
void
Asserts that an object is not undefined.
void
Asserts that an object is not undefined.
void
Asserts that an object is null.
void
Asserts that an object is null.
void
Asserts that two values are the same.
void
Asserts that two values are the same.
void
Asserts that a condition is true.
void
Asserts that a condition is true.
void
Asserts that an object is undefined.
void
Asserts that an object is undefined.
void
Fails a test.
void
Fails a test.
void
Fails a test.
Methods Detailed
assertEquals(expected, actual)
Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression.
Parameters
Returns: void
Sample
assertEquals(message, expected, actual)
Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression.
Parameters
Returns: void
Sample
assertFalse(boolean_condition)
Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false.
Parameters
Returns: void
Sample
assertFalse(message, boolean_condition)
Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false.
Parameters
Returns: void
Sample
assertFloatEquals(expectedFloat, actualFloat, tolerance)
Asserts that two floating point values are equal to within a given tolerance. AssertionFailedError is thrown if the expected value is not within the tolerance of the actual one.
Parameters
Returns: void
Sample
assertFloatEquals(message, expectedFloat, actualFloat, tolerance)
Asserts that two floating point values are equal to within a given tolerance. AssertionFailedError is thrown if the expected value is not within the tolerance of the actual one.
Parameters
Returns: void
Sample
assertMatches(regularExpression, actualString)
Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one.
Parameters
Returns: void
Sample
assertMatches(message, regularExpression, actualString)
Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one.
Parameters
Returns: void
Sample
assertNotNull(object)
Asserts that an object is not null. AssertionFailedError is thrown if the object is not null.
Parameters
Returns: void
Sample
assertNotNull(message, object)
Asserts that an object is not null. AssertionFailedError is thrown if the object is not null.
Parameters
Returns: void
Sample
assertNotSame(notExpected, actual)
Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one.
Parameters
Returns: void
Sample
assertNotSame(message, notExpected, actual)
Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one.
Parameters
Returns: void
Sample
assertNotUndefined(definedObject)
Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined.
Parameters
Returns: void
Sample
assertNotUndefined(message, definedObject)
Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined.
Parameters
Returns: void
Sample
assertNull(nullValue)
Asserts that an object is null. AssertionFailedError is thrown if the object is not null.
Parameters
Returns: void
Sample
assertNull(message, nullValue)
Asserts that an object is null. AssertionFailedError is thrown if the object is not null.
Parameters
Returns: void
Sample
assertSame(expected, actual)
Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one.
Parameters
Returns: void
Sample
assertSame(message, expected, actual)
Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one.
Parameters
Returns: void
Sample
assertTrue(boolean_condition)
Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true.
Parameters
Returns: void
Sample
assertTrue(message, boolean_condition)
Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true.
Parameters
Returns: void
Sample
assertUndefined(undefinedValue)
Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined.
Parameters
Returns: void
Sample
assertUndefined(message, undefinedValue)
Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined.
Parameters
Returns: void
Sample
fail(message)
Fails a test. AssertionFailedError is always thrown.
Parameters
Returns: void
Sample
fail(message, instanceOfCallStack)
Fails a test. AssertionFailedError is always thrown.
Parameters
Returns: void
Sample
fail(message, instanceOfCallStack, userMessage)
Fails a test. AssertionFailedError is always thrown.
Parameters
Returns: void
Sample
Last updated
Was this helpful?