As you release to production more and more often in SaaS, unit tests are a way to ensure the reliability of your code upstream. Whether your code is procedural or object-oriented with classes, Progress provides ABLUnit to make sure your programs work as intended.
01What is ABLUnit?
ABLUnit is a unit testing framework built into Progress Developer Studio for OpenEdge (PDSOE). It lets you create, run and manage unit tests for ABL (Advanced Business Language) programs.
02Key features
1. Test annotations
- Uses annotations such as @Test, @Before, @After, @Setup and @TearDown to identify and manage test methods.
- Annotations tell ABLUnit which methods to run before and after each test, as well as the test methods themselves.
2. Creating tests
- PDSOE provides wizards to create test classes, test procedures and test suites.
- Tests can be created manually by adding the required annotations, or with the built-in wizards.
3. Running tests
- Tests can be run directly from PDSOE using the Run As > ABLUnit Test option.
- ABLUnit generates an XML results file (results.xml) with the details of the tests run, including passes and failures.
4. Reporting and analysis
- Test results are shown in a dedicated view in PDSOE, for a quick analysis of passes and failures.
- Developers can use these reports to identify and fix bugs at code level.
03Benefits of ABLUnit
- Early bug detection: by testing units of code in isolation, developers can detect and fix bugs earlier in the development cycle.
- Easier maintenance: unit tests make code easier to maintain by ensuring that changes do not introduce new bugs.
- Code documentation: unit tests also act as living documentation of the code’s expected behaviour.
04A unit test example
Here is a simple example of a unit test class for an addition procedure:
/* addition.p */
PROCEDURE addition: DEFINE INPUT PARAMETER iNum1 AS INTEGER NO-UNDO. DEFINE INPUT PARAMETER iNum2 AS INTEGER NO-UNDO. DEFINE OUTPUT PARAMETER iResult AS INTEGER NO-UNDO. ASSIGN sc-camel-i-result = iNum1 + iNum2.
END PROCEDURE. /* test_addition.cls */
USING Progress.Lang.* FROM PROPATH.
USING Progress.Test.* FROM PROPATH. CLASS test_addition: @Test. METHOD PUBLIC VOID TestAddition(): DEFINE VARIABLE iResult AS INTEGER NO-UNDO. RUN addition (2, 3, OUTPUT iResult). ASSERT:ARE-EQUAL(5, iResult, "The result of the addition should be 5"). END METHOD. END CLASS.05Useful links
[1] Introduction video: OpenEdge: Using ABLUnit for Testing
[2] The basics: ABLUnit testing with the PDSOE ABL Unit testing framework
[3] Documentation within PDSOE: Creating test cases using ABLUnit - documentation.progress.com
Patrick


