1 JUnit
Class Ax.junit
JSUnit is a unit testing framework.
Test Syntax:
--------------
describe("iCON", "Sample Tests", (test) =
Method Summary
Modifier and Type
Method
Description
static void
Checks if the expected and found dates are equal.
static void
Checks if the expected and found dates are equal.
static void
assertEmpty(Object value)
Asserts that the value is empty.
static void
assertEmpty(Object value,Ax.text.String message)
Asserts that the value is empty.
static void
Asserts that the expected and found objects are equal.
static void
Asserts that the expected and found objects are equal.
static void
assertFalse(Ax.java.lang.Boolean value)
Asserts that the value is false.
static void
assertFalse(Ax.java.lang.Boolean value,Ax.text.String message)
Asserts that the value is false.
static void
assertNotEmpty(Object value)
Asserts that the value is not empty.
static void
assertNotEmpty(Object value,Ax.text.String message)
Asserts that the value is not empty.
static void
Asserts that the expected and found objects are not equal.
static void
Asserts that the expected and found objects are not equal.
static void
assertNotNull(Object value)
Asserts that the value is true.
static void
assertNotNull(Object value,Ax.text.String message)
Asserts that the value is true.
static void
assertNull(Object value)
Asserts that the value is true.
static void
assertNull(Object value,Ax.text.String message)
Asserts that the value is true.
static void
A single method with signature assertResultSet(TestSnapshot snapshot, Object object) is used to avoid graal
complaining about Multiple applicable overloads found for method name .
static void
Compares the results of a query (or more) defined by args, with a test snapshot from the previous execution.
static void
Compares the value of an object with a test snapshot from the previous execution.
static void
assertThrows(Runnable runnable)
Asserts that the function throws an exception.
static void
assertThrows(Runnable runnable, Ax.text.String message)
Asserts that the function throws an exception.
static void
assertThrows(Ax.text.String expectedErrorCode,Runnable runnable)
Asserts that the function throws an exception with the specified error code.
static void
assertThrows(Ax.text.String expectedErrorCode, Runnable functionBody, Ax.text.String message)
Asserts that the function throws an exception with the specified error code.
static void
Checks if the expected and found timestamps are equal.
static void
Checks if the expected and found timestamps are equal.
static void
assertTrue(boolean value)
Asserts that the value is true.
static void
assertTrue(boolean value, Ax.text.String message)
Asserts that the value is true.
static SQLResultSetArray
Represents a test suite execution.
static void
fail(Ax.text.String msg)
Fails the test throwing an exception with the defined message.
Method Detail
Ax.junit.assertDateEquals
-
static null Ax.junit.assertDateEquals( object expected, object found )
- Info:
-
Checks if the expected and found dates are equal. If not, throws an exception. - Parameters:
- expected - test expected date
- found - date found through test execution
- Returns:
- null
Ax.junit.assertDateEquals
-
static null Ax.junit.assertDateEquals( object expected, object found, string message )
- Info:
-
Checks if the expected and found dates are equal. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- expected - test expected date
- found - date found through test execution
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertEmpty
-
static null Ax.junit.assertEmpty( object value )
- Info:
-
Asserts that the value is empty. If not, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertEmpty
-
static null Ax.junit.assertEmpty( object value, string message )
- Info:
-
Asserts that the value is empty. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertEquals
-
static null Ax.junit.assertEquals( object expected, object found )
- Info:
-
Asserts that the expected and found objects are equal. If not, throws an exception. - Parameters:
- expected - test expected object
- found - object found through test execution
- Returns:
- null
Ax.junit.assertEquals
-
static null Ax.junit.assertEquals( object expected, object found, string message )
- Info:
-
Asserts that the expected and found objects are equal. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- expected - test expected object
- found - object found through test execution
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertFalse
-
static null Ax.junit.assertFalse( object value )
- Info:
-
Asserts that the value is false. If not, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertFalse
-
static null Ax.junit.assertFalse( object value, string message )
- Info:
-
Asserts that the value is false. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertNotEmpty
-
static null Ax.junit.assertNotEmpty( object value )
- Info:
-
Asserts that the value is not empty. If empty, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertNotEmpty
-
static null Ax.junit.assertNotEmpty( object value, string message )
- Info:
-
Asserts that the value is not empty. If empty, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertNotEquals
-
static null Ax.junit.assertNotEquals( object expected, object found )
- Info:
-
Asserts that the expected and found objects are not equal. If equal, throws an exception. - Parameters:
- expected - test expected object
- found - object found through test execution
- Returns:
- null
Ax.junit.assertNotEquals
-
static null Ax.junit.assertNotEquals( object expected, object found, string message )
- Info:
-
Asserts that the expected and found objects are not equal. If equal, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- expected - test expected object
- found - object found through test execution
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertNotNull
-
static null Ax.junit.assertNotNull( object value )
- Info:
-
Asserts that the value is true. If not, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertNotNull
-
static null Ax.junit.assertNotNull( object value, string message )
- Info:
-
Asserts that the value is true. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertNull
-
static null Ax.junit.assertNull( object value )
- Info:
-
Asserts that the value is true. If not, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertNull
-
static null Ax.junit.assertNull( object value, string message )
- Info:
-
Asserts that the value is true. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertResultSet
-
static null Ax.junit.assertResultSet( object snapshot, object object )
- Info:
-
A single method with signature assertResultSet(TestSnapshot snapshot, Object object) is used to avoid graal complaining about Multiple applicable overloads found for method name .... - Parameters:
- snapshot -
- object -
- Returns:
- null
Ax.junit.assertResultSet
-
static null Ax.junit.assertResultSet( object snapshot, object args )
- Info:
-
Compares the results of a query (or more) defined by args, with a test snapshot from the previous execution. If different, throws an exception. - Parameters:
- snapshot - test snapshot
- args - map(JSON) with args that define the query/ies
- Returns:
- null
Ax.junit.assertText
-
static null Ax.junit.assertText( object snapshot, object value )
- Info:
-
Compares the value of an object with a test snapshot from the previous execution. If different, throws an exception. - Parameters:
- snapshot - test snapshot
- value - value to assert
- Returns:
- null
Ax.junit.assertThrows
-
static null Ax.junit.assertThrows( object runnable )
- Info:
-
Asserts that the function throws an exception. If it does not throw an exception, an exception is thrown. - Parameters:
- runnable - function to check
- Returns:
- null
Ax.junit.assertThrows
-
static null Ax.junit.assertThrows( object runnable, string message )
- Info:
-
Asserts that the function throws an exception. If it does not throw an exception, an exception with the specified message is thrown. If message is null, the exception will have the default message. - Parameters:
- runnable - function to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertThrows
-
static null Ax.junit.assertThrows( string expectedErrorCode, object runnable )
- Info:
-
Asserts that the function throws an exception with the specified error code. If it does not throw an exception, or the error code is different, an exception is thrown. - Parameters:
- expectedErrorCode - expected error code that the function will throw
- runnable - function to check
- Returns:
- null
Ax.junit.assertThrows
-
static null Ax.junit.assertThrows( string expectedErrorCode, object functionBody, string message )
- Info:
-
Asserts that the function throws an exception with the specified error code. If it does not throw an exception, or the error code is different, an exception with the specified message is thrown. If message is null, the exception will have the default message. - Parameters:
- expectedErrorCode - expected error code that the function will throw
- functionBody - function to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertTimestampEquals
-
static null Ax.junit.assertTimestampEquals( object expected, object found )
- Info:
-
Checks if the expected and found timestamps are equal. If not, throws an exception. - Parameters:
- expected - test expected timestamp
- found - timestamp found through test execution
- Returns:
- null
Ax.junit.assertTimestampEquals
-
static null Ax.junit.assertTimestampEquals( object expected, object found, string message )
- Info:
-
Checks if the expected and found timestamps are equal. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- expected - test expected timestamp
- found - timestamp found through test execution
- message - message for the exception to throw
- Returns:
- null
Ax.junit.assertTrue
-
static null Ax.junit.assertTrue( boolean value )
- Info:
-
Asserts that the value is true. If not, throws an exception. - Parameters:
- value - value to check
- Returns:
- null
Ax.junit.assertTrue
-
static null Ax.junit.assertTrue( boolean value, string message )
- Info:
-
Asserts that the value is true. If not, throws an exception with specified message. If message is null, the exception will have the default message. - Parameters:
- value - value to check
- message - message for the exception to throw
- Returns:
- null
Ax.junit.describe
-
static resultset Ax.junit.describe( string junitModule, string junitName, object testSuiteBody )
- Info:
-
Represents a test suite execution. All tests wihtin describe function are executed inside a transaction that is rolled back when all tests have finished. The ResultSet returned contains a row for each test, with data about its execution. - Parameters:
- junitModule - the module the test suite belongs to
- junitName - the name or title for the suite
- testSuiteBody - a block of code implemented by the suite
- Returns:
- resultset
Example
Copy
const result = Ax.junit.describe('DOCS', 'Docs Test Suite', (test) => { test('TEST 1', (testunit) => { // assertions here }); test('TEST 2', (testunit) => { // assertions here }); }); return result;
Ax.junit.fail
-
static null Ax.junit.fail( string msg )
- Info:
-
Fails the test throwing an exception with the defined message. - Parameters:
- msg -
- Returns:
- null