TRansactional API Test (TRAPIT) utility packages for Oracle plus demo base and test programs for Oracle's HR demo schema.
The test utility packages and types are designed as a lightweight PL/SQL-based framework for API testing that can be considered as an alternative to utPLSQL. The framework is based on the idea that all API testing programs can follow a universal design pattern for testing APIs, using the concept of a ‘pure’ function as a wrapper to manage the ‘impurity’ inherent in database APIs. I explained the concepts involved in a presentation at the Oracle User Group Ireland Conference in March 2018:
The following article provides example output and links to articles describing design patterns the framework is designed to facilitate, as well as anti-patterns it is designed to discourage:
6 July 2018: json_input_output feature branch created that moves all inputs out of the packages and into JSON files, and creates output JSON files that include the actuals. A new table is added to store the input and output JSON files by package and procedure. The output files can be used as inputs to a Nodejs program, recently added to GitHub, to produce result reports formatted in both HTML and text. The input JSON files are read into the new table at installation time, and read from the table thereafter. The Nodejs project includes the formatted reports for this Oracle project. The output JSON files are written to Oracle directory input_dir (and the input JSON files are read from there), but I have copied them into the project oracle root for reference.
In order to run the demo unit test suite, you must have installed Oracle's HR demo schema on your Oracle instance:
There are no other dependencies outside this project, other than that the latest, JSON, version produces JSON outputs but not formatted reports, which can be obtained from my Nodejs project, mentioned above. I may add a PL/SQL formatter at a later date.
The testing utility packages use my own simple logging framework, installed as part of the installation scripts. To replace this with your own preferred logging framework, simply edit the procedure Utils.Write_Log to output using your own logging procedure, and optionally drop the log_headers and log_lines tables, along with the three Utils.*_Log methods.
As far as I know, prior to the latest JSON version, the code should work on any recent-ish version - I have tested on 11.2 and 12.1. The JSON version may require 12.2.
Extract all the files into a directory Update Install_SYS.sql to ensure Oracle directory input_dir points to a writable directory on the database sever (in repo now is set to 'C:\input') Copy the input JSON files to the directory pointed to by input_dir: TT_EMP_BATCH.tt_AIP_Load_Emps.json TT_EMP_WS.tt_AIP_Get_Dept_Emps.json TT_EMP_WS.tt_AIP_Save_Emps.json TT_VIEW_DRIVERS.tt_HR_Test_View_V.json Run Install_SYS.sql as a DBA passing new library schema name as parameter (eg @Install_SYS trapit) Run Install_HR.sql from the HR schema passing library utilities schema name as parameter (eg @Install_HR trapit) Run Install_Bren.sql from the schema for the library utilities (@Install_Bren) Check log files for any errors
Running the demo test suite
Run R_Suite_br.sql from the schema for the library utilities in the installation directory.
I have included a java program that can be used to call the web service base procedure. This is not required for the Oracle code, but I thought it might make a useful template for JDBC integration testing: