Declarative test packages
Documentation status: guide — see Maturity and evidence.
Application tests can live in a dedicated package while following the same loading rules as production models. Merely placing a test file in the source tree does not activate it: the test package, schema path, manifest, and application configuration must make the suite reachable.
Recommended layout
my-module/
packages/
MyModule.package.yaml
MyModule.Tests.package.yaml
meta/models/
MyModule/
ClassItems.manifest.yaml
Customer.model.yaml
MyModuleTests/
ClassItems.manifest.yaml
CustomerModelTests.model.yaml
CustomerActionTests.model.yaml
A test package descriptor can use the same package shape:
package:
items:
- MyModuleTests:
caption: '#MyModuleTests'
enabled: true
files:
schemaDirectories:
schemaPath:
value: '[Modules]/my-module/meta/models'
The public form of a manifest keeps implementation bindings normalized:
package:
objectsContainer: CustomObjectsContainer
plugginCaption: My Module Tests
uri: http://www.logicells.net/schema/MyModuleTests
classes:
- CustomerModelTests:
classId: myapp#customer_model_tests
type: Entity
- CustomerActionTests:
classId: myapp#customer_action_tests
type: Entity
Test suite model
A declarative test suite is an Entity concept that explicitly implies lgc#unit_test.
class:
name: CustomerModelTests
classId: myapp#customer_model_tests
className: CustomClassItem
currentGeneratorName: MyModuleTests.CustomerModel
type: Entity
generators:
- MyModuleTests.CustomerModel:
class: GUIDStringGeneratorInfo
params: ''
object:
className: CustomObjectItem
objectName: CustomerModelTests
concepts:
- Entity:
constraints:
- implies: lgc#unit_test
Each Action declared directly by the suite represents a test case. For a scripted test action, the normalized public class name is UnitTestScriptableObjectElementAction.
actions:
- action:
name: Customer_Class_Is_Loaded
class: UnitTestScriptableObjectElementAction
type: ClassItem
published: true
scripts:
- script:
clientScript: true
serverScript: false
language: functionalP
classes: Desktop
cdata: |
TargetClassItem := Self.ObjectsContainer.ClassItemByClassId('myapp#customer');
Self.Assert(GUnitTest, (TargetClassItem <> nil), 'Customer ClassItem is not loaded');
Use several small actions grouped by contract rather than one large test action.