Running a Test




Running a test from the Editor Context Menu   Top

If you're using OpenEdge Architect, and have followed the instructions in Installation Step 4: Add a Menu Action to OpenEdge Architect , this is the recommended method to run a test.

1. In OpenEdge Architect, open the test case or test suite you wish to run.

2. From the ABL Editor, right click to open the context menu and then click Extensibility > Run As Test.

ABL Editor Context Menu


3. The test will run in the background. Once its finished, the results should appear in a new view in OpenEdge Architect (shown below).

Test Results Window



Running a test from code   Top

Option 1. Using the OEUnit.Runners.RunTest helper (runs the test and displays the results):

 ROUTINE-LEVEL ON ERROR UNDO, THROW.

 USING OEUnit.Runners.RunTest.

 /* Create an instance of the test case */
 DEFINE VARIABLE test AS SimpleTest NO-UNDO.
 test = NEW SimpleTest().
 
 /* Run the test and display the results */
 RunTest:WithDefault(test).

 /* Delete the test case */
 FINALLY:
   DELETE OBJECT test NO-ERROR.
 END FINALLY.


Option 2. Using a runner directly:

 ROUTINE-LEVEL ON ERROR UNDO, THROW.

 USING OEUnit.Runners.OEUnitRunner.

 /* Create an instance of the test suite */
 DEFINE VARIABLE suite AS SimpleSuite NO-UNDO.
 suite = NEW SimpleSuite().
 
 /* Create an instance of the runner */
 DEFINE VARIABLE runner AS OEUnitRunner NO-UNDO.
 runner = NEW OEUnitRunner().

 /* Run the test suite */
 runner:RunTest(suite).

 /* Display the results */
 MESSAGE runner:Results:ToString() VIEW-AS ALERT-BOX.

 /* Delete the test suite and runner */
 FINALLY:
   DELETE OBJECT suite NO-ERROR.
   DELETE OBJECT runner NO-ERROR.
 END FINALLY.



Cameron Wills, 2011.