Article
· Jul 30 3m read

Toolqa - The wait is over

Well... It's time for testing. We know that often, it's already over. So, what now? Can I improve the quality of my development?

The answer is: YES. Yes, you can. The Toolqa tool aims to do just that. It's a facilitator. What's its goal?

To ensure that APIs meet pre-established business requirements, while also protecting against <sarcasm>  future failed attempts </sarcasm>  to destroy your application, website, app, or anything else that uses your API.

Now you might be wondering, how does this happen? Where's the magic?

The ToolQA.tool.BP.Tool class was designed as an intelligent and automated testing agent for API classes in InterSystems IRIS, and its main objectives are:

  1. Automatically generate (from the selection of a class) new test classes for any API class;
  2. Evaluate the API class's own methods and parameters using IRIS class metadata;
  3. Generate several synthetic test values for each method parameter based on its type (Integer, String, Float, Date, etc.);
  4. Compare these test values against your database schema before invoking the API method, ensuring type and limit compliance;
  5. Compile and save the generated test class in the IRIS environment;
  6. Provide an executable Run() method within the generated test class to run the tests and report the results.

Okay, I get it, but how do I do this? Just follow the steps below:

Input

You call the method:

DO ##class(ToolQA.tool.BP.Tool).GenerateTestForClass(“Your.API.ClassName”)
with the fully qualified name of the API class you want to test.

  1. Introspection and Metadata Analysis The tool uses IRIS’ %Dictionary.ClassDefinition to:

Open the API class definition;

Enumerate all public class methods;

Extract each method’s parameter names and types.

  1. Synthetic Test Data Generation For each method parameter:

The method CreateFakeValue generates a dummy value compatible with the parameter’s type (e.g., string, integer, double);

The tool attempts to find a mapping between parameters and persistent database classes/fields through the ClassBank method, scanning known persistent classes for matching fields;

If a mapping exists, the generated dummy value is validated against the database field’s type and constraints (ValidateValueField), checking type correctness, length limits, and numeric bounds.

  1. Test Class Generation The agent dynamically creates a new test class with the naming convention:

ToolQA.QA.Tests.Test
The class contains a Run() class method that:

Prints the test start message;

Executes each API method with generated parameters, after validation;

Catches and logs errors or exceptions during method calls;

Reports test success or failure.

  1. Compilation and Execution The generated test class is saved as a .cls file and compiled automatically within IRIS. You then execute tests by running:

DO ##class(ToolQA.QA.Tests.Test).Run()
How Responses and Results Are Handled
The test class captures the return status (%Status) of each API method call;

Errors (non-success status codes) are printed to the console with details;

Exceptions thrown by API methods are caught and logged with their stack trace;

Since the agent generates synthetic inputs, it does not currently validate response content beyond execution success — but you can extend the test class to add assertions on output objects or returned data structures as needed.

For more information about the tool and how to proceed, you can access the link:

https://openexchange.intersystems.com/package/toolqa

This tool was built together with @André Dienes Friedrich. Thank you for your consideration... And the sky is the limit.

 

Discussion (0)2
Log in or sign up to continue