Type to start searching...

UnitTest

A set of test cases to test Model functionality.

Description

A unit test tests functional components of the Business Model. It is run as part of an automated test to verify that the model is functioning as expected. A unit test consists of an initializer, a finalizer and a set of test cases. Test cases are essentially script with access to special assert statements used to compare actual to expected results.

The initializer and finalizer are run before and after each test case regardless of the UnitTest's mode ("sequential" or "dirty"). The initializer is typically used to set up test conditions and the finalizer to clean up unmanaged resources.

If a UnitTest's mode property is set to "sequential" a clean dump file, specified in the "dump" property, is restored prior to running each test case. This is to ensure that there are no side-effects between tests.

If a UnitTest's mode property is set to "dirty" the dump file will be restored only once prior to running the first test case. Subsequent test cases will execute immediately following the previous test without a clean restore.

Note that in "dirty" mode you shouldn't rely on the initializer and finalizer to set up and tear down data and resources as they are run before and after each test case. If you want to initialize data in "dirty" mode you could insert a test case at the beginning of the UnitTest and use it to do initialization. Similarly, if you want to clean up unmanaged resources at the end of a "dirty" UnitTest, insert a final test case to perform cleanup.

An optional list of variables may be used to pass state from one test case to another. As an example, another approach to the question of how to initialize a UnitTest in "dirty" mode could be to use a variable called "firstCase". This variable could be used to determine what script to run in the initializer. Even though the initializer runs before each test case, the code in the initializer would only run when the "firstCase" variable was true. "firstCase" would be set to false after the initializer was run the first time.

You may use the Loop construct to loop over the UnitTest with any combination of "looped" variables. During each iteration one of the variables will advance to the next value in its list of values. In this way, the UnitTest will be evaluated against the combination of all sets of variables.

Properties
description : string

A description of what functional area the unit test covers.

dump : string

The database dump file used to import a new seeded database.

The database dump will be restored before each test case in "sequential" mode or only once at the beginning of the unit test in "dirty" mode.
initializedOnce : boolean

Run the initializer only once before all test cases (for "dirty" mode only). Default behavior is to run once before each test case.

mode

The run mode. "dirty" means no database resetting is required between each test case run.

Valid values based on“string”.
sequential

The database dump will be restored before each test case is run.

dirty

The database dump will be restored once at the beginning of the unit test.

properties : string

Test configuration properties.

These can be used to parameterize data seeding, e.g. '((hierarchySecurityEnabled . #t) ...)
variables : identifierList

Unit Test variables: var1 var2 ... varN; global to initializer, finalizer, and test cases.

Initialized to null at the start of the test and at the beginning of each loop.
Valid values based on“token”.
(:?[\p{L}_][\p{L}\p{N}_]*(:[\p{L}_][\p{L}\p{N}_]*)*\s+)*(:?[\p{L}_][\p{L}\p{N}_]*(:[\p{L}_][\p{L}\p{N}_]*)*)?

Each element in the list must begin with a letter or underscore. Elements are space delimited.

Content
  • Sequence of:

    • Loops [0..1]

    • Initializer [0..1] - Code that will execute before each test case.

    • TestCase [0..*] - Script used to test a unit of functionality in a unit test

    • Finalizer [0..1] - Code that will execute after each test case.