Test Procedure
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
A test procedure is an ABL procedure file that has one or more internal test procedures. All the naming requirements of the test procedure are similar to ABL procedures.
Here is an example of an ABL procedure file; any procedure can be converted to a
test procedure by adding
@Test annotation as shown in
the
example./File: InternalProcedureToTest.p/
PROCEDURE P1:
DEFINE OUTPUT PARAMETER out AS INTEGER.
out = 20.
END PROCEDURE.
The following is the test procedure for the above
procedure.
ROUTINE-LEVEL ON ERROR UNDO, THROW.
USING OpenEdge.Core.Assert.
@Test.
PROCEDURE TestP1:
DEFINE VARIABLE hproc AS HANDLE NO-UNDO.
DEFINE VARIABLE out AS INTEGER.
RUN InternalProcedureToTest.p PERSISTENT SET hProc.
RUN p1 IN hProc (OUTPUT out).
Assert:equals(20,out).
END PROCEDURE.
Note: The
RUN PERSISTENT might typically be placed
in a @Before or @Setup
procedure to avoid repeating code in a test case that runs multiple internal
procedures.