1 JUnit

Class Ax.junit


Test Syntax: -------------- describe("iCON", "Sample Tests", (test) =

Method Summary

Modifier and TypeMethodDescription
static void assertDateEquals(Object expected, Object found)Checks if the expected and found dates are equal.
static void assertDateEquals(Object expected, Object found, String message)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, String message)Asserts that the value is empty.
static void assertEquals(Object expected, Object found)Asserts that the expected and found objects are equal.
static void assertEquals(Object expected, Object found, String message)Asserts that the expected and found objects are equal.
static void assertFalse(boolean value)Asserts that the value is false.
static void assertFalse(boolean value, 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, String message)Asserts that the value is not empty.
static void assertNotEquals(Object expected, Object found)Asserts that the expected and found objects are not equal.
static void assertNotEquals(Object expected, Object found, String message)Asserts that the expected and found objects are not equal.
static void assertResultSet(TestSnapshot snapshot, List<Map> args)Compares the results of a query (or more) defined by args, with a test snapshot from the previous execution.
static void assertResultSet(TestSnapshot snapshot, Object[] args)Compares the results of a query (or more) defined by args, with a test snapshot from the previous execution.
static void assertResultSet(TestSnapshot snapshot, Map args)Compares the results of a query (or more) defined by args, with a test snapshot from the previous execution.
static void assertText(TestSnapshot snapshot, Object value)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, String message)Asserts that the function throws an exception.
static void assertThrows(String expectedErrorCode, Runnable runnable)Asserts that the function throws an exception with the specified error code.
static void assertThrows(String expectedErrorCode, Runnable functionBody, String message)Asserts that the function throws an exception with the specified error code.
static void assertTimestampEquals(Object expected, Object found)Checks if the expected and found timestamps are equal.
static void assertTimestampEquals(Object expected, Object found, String message)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, String message)Asserts that the value is true.
static SQLResultSetArray describe(String junitModule, String junitName, Consumer<TestSuite> testSuiteBody)Represents a test suite execution.
static void fail(String msg)Fails the test throwing an exception with the defined message.
static InputStream getResource(String name)
static void setResourcePath(Class clazz)

Method Detail

assertDateEquals

static void 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

assertDateEquals

static void 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

assertEmpty

static void assertEmpty(Object value)
Info:
Asserts that the value is empty. If not, throws an exception.
Parameters:
value - value to check

assertEmpty

static void 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

assertEquals

static void 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

assertEquals

static void 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

assertFalse

static void assertFalse(boolean value)
Info:
Asserts that the value is false. If not, throws an exception.
Parameters:
value - value to check

assertFalse

static void assertFalse(boolean 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

assertNotEmpty

static void assertNotEmpty(Object value)
Info:
Asserts that the value is not empty. If empty, throws an exception.
Parameters:
value - value to check

assertNotEmpty

static void 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

assertNotEquals

static void 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

assertNotEquals

static void 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

assertResultSet

static void assertResultSet(TestSnapshot snapshot, List<Map> 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

Example
Copy
Ax.junit.assertResultSet(testunit.snapshot, [{
     tableName: "capuntes",
     columns: "diario,moneda,cambio,empcode,proyec",
     where: "placon = 'XJU'",
     order: "cuenta"
 }, ..]);

assertResultSet

static void assertResultSet(TestSnapshot 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

assertResultSet

static void assertResultSet(TestSnapshot snapshot, Map 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

assertText

static void assertText(TestSnapshot 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

assertThrows

static void assertThrows(Runnable 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

assertThrows

static void assertThrows(Runnable 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

assertThrows

static void assertThrows(String expectedErrorCode, Runnable 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

assertThrows

static void assertThrows(String expectedErrorCode, Runnable 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

assertTimestampEquals

static void 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

assertTimestampEquals

static void 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

assertTrue

static void assertTrue(boolean value)
Info:
Asserts that the value is true. If not, throws an exception.
Parameters:
value - value to check

assertTrue

static void 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

describe

static SQLResultSetArray describe(String junitModule, String junitName, Consumer<TestSuite> 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:
the result given by the test suite execution

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;

fail

static void fail(String msg)
Info:
Fails the test throwing an exception with the defined message.
Parameters:
msg - 

getResource

static InputStream getResource(String name)
Parameters:
name - 
Returns:

setResourcePath

static void setResourcePath(Class clazz)
Parameters:
clazz -