Try OpenEdge Now
skip to main content
Online Help
Overview of ABLUnit testing framework : Concepts : Test Class
 

Test Class

A test class is an ABL class that contains one or more test methods. All the naming requirements of the test class are similar to ABL class.
Here is an example of an ABL class file; any method in a test class can be converted to a test method by adding @Test annotation as shown in the example.
USING Progress.Lang.*.
CLASS MyClass:
METHOD PUBLIC CHARACTER M1( ):
DEFINE VARIABLE result AS CHARACTER NO-UNDO.
result = "M1".
RETURN result.
END METHOD.
METHOD PUBLIC INTEGER M2( ):
DEFINE VARIABLE result AS INTEGER NO-UNDO.
result = 10.
RETURN result.
END METHOD.
END CLASS.
Here is the ABLUnit test class for the above class file:
ROUTINE-LEVEL ON ERROR UNDO, THROW.
USING OpenEdge.Core.Assert.
CLASS MyTestClass:
@Test.
METHOD PUBLIC VOID TestM1( ):
DEFINE VARIABLE obj AS MyClass NO-UNDO.
DEFINE VARIABLE returned AS CHARACTER NO-UNDO.
obj = new MyClass().
returned = obj:M1().
Assert:equals("M1",returned).
END METHOD.
@Test.
METHOD PUBLIC VOID TestM2( ):
DEFINE VARIABLE obj AS MyClass NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
obj = new MyClass().
i = obj:M2().
Assert:equals(0,i).
END METHOD.
END CLASS.