Lifecycle of ABLUnit framework
- Last Updated: February 11, 2026
- 5 minute read
- OpenEdge
- Version 13.0
- Documentation
The ABLUnit testing framework uses annotations to specify that a method in a test class or an internal procedure in a test procedure is a test case.
In ABLUnit, every test should be annotated with @Test annotation.
A test case procedure or test case class can have one
BeforeAll and AfterAll method or procedure which
are annotated with @BeforeAll and @AfterAll methods.
These are run either before all tests or after all tests, respectively.
@Before and @After which were ambiguous. The new
annotation names are more explicit in their function, though the older annotation names
are still supported.A test case procedure or a test case class can have any number of tests and multiple
BeforeEach and AfterEach methods or procedures
which are annotated with @BeforeEach and @AfterEach.
These are run before each, or after each, test, respectively.
@Setup and @Teardown which were ambiguous. The new
annotation names are more explicit in their function, though the older annotation names
are still supported.The ABLUnit testing framework can be invoked, for example, by providing a test class or a test procedure. The framework identifies the tests by looking for test annotations associated with methods or procedures. The execution of a test case proceeds in the following sequence:
- If a method or procedure is marked with the
@BeforeAllannotation, it is executed before any tests. - For each test method or procedure:
@BeforeEachannotated method or procedure is executed, if there is any.- The test method or procedure is executed.
@AfterEachannotated method or procedure is executed, if there is any.
- If a method or procedure marked with the
@AfterAllannotation is present, it is executed after executing all the tests.
Updates to ABLUnit
OpenEdge.ABLUnit namespaces may need to be
recompiled or updated to use the new public API (classes and methods). The following
changes require the modification and removal of a number of public members:- Methods with lifecycle annotations
- Lifecycle method failure and error reporting
errNumkey for expected error numbers- Failure and errors written to
results.xml <skipped>element for ignored tests- Stop conditions caught
<properties>element for test suites@Testsuiteor@Testannotations required
results.xml file with the JUnit results
standard.Methods with lifecycle annotations
The ABLUnit test framework has the concept of lifecycle methods that add behavior to test cases and individual tests, for instance, code that must run before each test method. Previous releases allowed multiple methods with the same annotation to be run, but at run time, only a single lifecycle method was run.
Now, all of the methods that have lifecycle annotations are run
in the order in which they are defined. Methods must all have the same signature
(return void, no parameters), but the OOABL
class requires the methods to have different names.
BeforeEach_A and
BeforeEach_B both run before Test1 runs.
|
In order for multiple methods with lifecycle annotations to be run, additional behavior changes were made.
Lifecycle method failure and error reporting
A test that returns OpenEdge.Core.AssertionFailedError is a failure because a
particular assertion was tested. All other conditions raised are considered
errors.
If a test method has one or more lifecycle methods, and one of those methods (either the test method itself or one or more of the lifecycle methods) raises any error, then the most severe condition raised is reported. For example, if the test method raises a failure due to an assertion failing, and the lifecycle method raises an error, then the error is reported because an error is more severe than a failure.
errNum key for expected error numbers
@Test annotation enables
developers to specify the type of exception raised using an expected key with an
OOABL type name value. To specify an error
number, use the errNum key. The value for
errNum must be an integer. The test passes
if the following are true: - The test raises an exception, and the exception matches the expected type.
- An
errNumvalue is provided. - The exception's first error number equals the
errNumvalue.
If no errNum key is provided,
then only the expected type is used to determine a test's success.
For example, the following test passes because it does not expect the class to exist.
|
Failures and errors written to result.xml
A single test may have zero, one, or more lifecycle methods associated with
it. The @BeforeEach and @AfterEach methods run before and after each test method,
respectively. Failures or errors resulting from the test method or its lifecycle
methods each have a failure or error element created in the results.xml file.
For example, there are two failures in the test named test3:
|
<skipped> element for ignored tests
If a test is ignored, then a <skipped> element is added with a message attribute.
|
Stop conditions caught
ABLUnit handles stop conditions raised in test methods
(explicitly or implicitly). The message written to the results.xml varies depending on the value of the -catchStop parameter.
If the -catchStop parameter has
a value of 0, then the Progress.Lang.AppError
error is raised and caught, and the message "stop condition raised for <test-name>" is added as an error to the
test result.
If the -catchStop parameter has
a value of 1, then the Progress.Lang.Stop
exception is caught, and an error message is added to the test results. The
message is typically "Stop condition raised" except for lock conflicts. If there
is a lock conflict, then the message is "Lock conflict raised".
<properties> element for test suites
A <properties> element is
added to <testcase> (test classes and
procedures) <testsuite> elements. This
element contains a number of properties that describe the session.
The following is a list of properties and the ABL functions or attributes used to determine their values:
|
@TestSuite or @Test annotation required
@TestSuite annotation or at least one @Test annotation are considered tests, and are added to the list of tests
to run. All other programs are ignored by the ABLUnit test runner.