Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression. |
|
Parameters {Object} expected – the expected value.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression.
jsunit.assertEquals("Solution name test", "someSolution", application.getSolutionName());
jsunit.assertEquals("Simple math test", 2, 1 + 1);
|
|
|
|
|
(message, expected, actual) |
|
|
Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression. |
|
Parameters {String} message – The test description/message.
{Object} expected – the expected value.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are equal. AssertionFailedError is thrown if the actual value does not match the regular expression.
jsunit.assertEquals("Solution name test", "someSolution", application.getSolutionName());
jsunit.assertEquals("Simple math test", 2, 1 + 1);
|
|
|
|
|
Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false. |
|
Parameters {Boolean} boolean_condition – the actual value. |
|
Sample
// Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false.
jsunit.assertFalse("False test", application.isLastPrintPreviewPrinted());
|
|
|
|
|
(message, boolean_condition) |
|
|
Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false. |
|
Parameters {String} message – The test description/message.
{Boolean} boolean_condition – the actual value. |
|
Sample
// Asserts that a condition is false. AssertionFailedError is thrown if the evaluation was not false.
jsunit.assertFalse("False test", application.isLastPrintPreviewPrinted());
|
|
|
|
|
(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 {Number} expectedFloat – the expected value.
{Number} actualFloat – the actual value.
{Number} tolerance – tolerance when comparing. |
|
Sample
// 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.
jsunit.assertFloatEquals("Float equals test", 3.12, 3.121, 0.0015);
|
|
|
|
|
(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 {String} message – The test description/message.
{Number} expectedFloat – the expected value.
{Number} actualFloat – the actual value.
{Number} tolerance – tolerance when comparing. |
|
Sample
// 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.
jsunit.assertFloatEquals("Float equals test", 3.12, 3.121, 0.0015);
|
|
|
|
|
(regularExpression, actualString) |
|
|
Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one. |
|
Parameters {Object} regularExpression – the regular expression used for matching.
{String} actualString – the actual value to be matched. |
|
Sample
// Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one.
jsunit.assertMatches(new RegExp("gr(a|e)y"), "gray");
|
|
|
|
|
(message, regularExpression, actualString) |
|
|
Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one. |
|
Parameters {String} message – The test description/message.
{Object} regularExpression – the regular expression used for matching.
{String} actualString – the actual value to be matched. |
|
Sample
// Asserts that a regular expression matches a string. AssertionFailedError is thrown if the expected value is not the actual one.
jsunit.assertMatches("Match test", new RegExp("gr(a|e)y"), "gray");
|
|
|
|
|
Asserts that an object is not null. AssertionFailedError is thrown if the object is not null. |
|
Parameters {Object} object – the actual value. |
|
Sample
// Asserts that an object is not null. AssertionFailedError is thrown if the object is not null.
var a; // this is undefined, not null
jsunit.assertNotNull(a);
|
|
|
|
|
Asserts that an object is not null. AssertionFailedError is thrown if the object is not null. |
|
Parameters {String} message – The test description/message.
{Object} object – the actual value. |
|
Sample
// Asserts that an object is not null. AssertionFailedError is thrown if the object is not null.
var a; // this is undefined, not null
jsunit.assertNotNull("Not null test", a);
|
|
|
|
|
Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one. |
|
Parameters {Object} notExpected – the value that is not expected.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one.
var a = new Date(1990, 1, 1);
var b = new Date(1990, 1, 1);
jsunit.assertNotSame(a, b);
jsunit.assertEquals("But equals", a, b);
|
|
|
|
|
(message, notExpected, actual) |
|
|
Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one. |
|
Parameters {String} message – The test description/message.
{Object} notExpected – the value that is not expected.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are not the same. AssertionFailedError is thrown if the expected value is the actual one.
var a = new Date(1990, 1, 1);
var b = new Date(1990, 1, 1);
jsunit.assertNotSame("Not same test", a, b);
jsunit.assertEquals("But equals", a, b);
|
|
|
|
|
Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined. |
|
Parameters {Object} definedObject – the actual value. |
|
Sample
// Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined.
var a = 0;
jsunit.assertNotUndefined(a);
|
|
|
|
|
Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined. |
|
Parameters {String} message – The test description/message.
{Object} definedObject – the actual value. |
|
Sample
// Asserts that an object is not undefined. AssertionFailedError is thrown if the object is undefined.
var a = 0;
jsunit.assertNotUndefined("Not undefined test", a);
|
|
|
|
|
Asserts that an object is null. AssertionFailedError is thrown if the object is not null. |
|
Parameters {Object} nullValue – the actual value. |
|
Sample
// Asserts that an object is null. AssertionFailedError is thrown if the object is not null.
jsunit.assertNull("Null test", null);
|
|
|
|
|
Asserts that an object is null. AssertionFailedError is thrown if the object is not null. |
|
Parameters {String} message – The test description/message.
{Object} nullValue – the actual value. |
|
Sample
// Asserts that an object is null. AssertionFailedError is thrown if the object is not null.
jsunit.assertNull("Null test", null);
|
|
|
|
|
Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one. |
|
Parameters {Object} expected – the expected value.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one.
var a = new Date(1990, 1, 1);
var b = a;
jsunit.assertSame(a, b);
|
|
|
|
|
(message, expected, actual) |
|
|
Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one. |
|
Parameters {String} message – The test description/message.
{Object} expected – the expected value.
{Object} actual – the actual value. |
|
Sample
// Asserts that two values are the same. AssertionFailedError is thrown if the expected value is not the actual one.
var a = new Date(1990, 1, 1);
var b = a;
jsunit.assertSame("Same test", a, b);
|
|
|
|
|
Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true. |
|
Parameters {Boolean} boolean_condition – the actual value. |
|
Sample
// Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true.
jsunit.assertTrue("True test", application.isLastPrintPreviewPrinted());
|
|
|
|
|
(message, boolean_condition) |
|
|
Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true. |
|
Parameters {String} message – The test description/message.
{Boolean} boolean_condition – the actual value. |
|
Sample
// Asserts that a condition is true. AssertionFailedError is thrown if the evaluation was not true.
jsunit.assertTrue("True test", application.isLastPrintPreviewPrinted());
|
|
|
|
|
Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined. |
|
Parameters {Object} undefinedValue – the actual value. |
|
Sample
// Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined.
jsunit.assertUndefined("Undefined test", thisIsUndefined);
|
|
|
|
|
(message, undefinedValue) |
|
|
Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined. |
|
Parameters {String} message – The test description/message.
{Object} undefinedValue – the actual value. |
|
Sample
// Asserts that an object is undefined. AssertionFailedError is thrown if the object is defined.
jsunit.assertUndefined(thisIsUndefined);
|
|
|
|
|
Fails a test. AssertionFailedError is always thrown. |
|
Parameters {String} message – The test description/message. This is usually the only parameter specified when calling this method. |
|
Sample
// Fails a test. AssertionFailedError is always thrown.
jsunit.fail("Fail test");
jsunit.fail("test", null, "Fail"); // 2nd param is not used in Servoy, params 3 and 1 get merged to form a message. The result is the same as in the line above.
|
|
|
|
|
(message, instanceOfCallStack) |
|
|
Fails a test. AssertionFailedError is always thrown. |
|
Parameters {String} message – The test description/message. This is usually the only parameter specified when calling this method.
{Object} instanceOfCallStack – an internal JSUnit call stack. Use null for this if you want to get to the next optional parameter. Usually not specified. |
|
Sample
// Fails a test. AssertionFailedError is always thrown.
jsunit.fail("Fail test");
jsunit.fail("test", null, "Fail"); // 2nd param is not used in Servoy, params 3 and 1 get merged to form a message. The result is the same as in the line above.
|
|
|
|
|
(message, instanceOfCallStack, userMessage) |
|
|
Fails a test. AssertionFailedError is always thrown. |
|
Parameters {String} message – The test description/message. This is usually the only parameter specified when calling this method.
{Object} instanceOfCallStack – an internal JSUnit call stack. Use null for this if you want to get to the next optional parameter. Usually not specified.
{String} userMessage – a user message. Usually not specified. |
|
Sample
// Fails a test. AssertionFailedError is always thrown.
jsunit.fail("Fail test");
jsunit.fail("test", null, "Fail"); // 2nd param is not used in Servoy, params 3 and 1 get merged to form a message. The result is the same as in the line above.
|
|
|
|
|
|