Skip to main content
Glama

RunUnitTest

Execute ABAP Unit tests for specified container and test classes. Returns a run ID to track test status and results.

Instructions

Start an ABAP Unit test run for provided class test definitions. Returns run_id for status/result queries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testsYesList of container/test class pairs to execute.
titleNoOptional title for the ABAP Unit run.
contextNoOptional context string shown in SAP tools.
scopeNo
risk_levelNo
durationNo

Implementation Reference

  • Main handler function for RunUnitTest tool. Uses AdtClient.getUnitTest().create() to start ABAP Unit test runs and returns a run_id for status/result queries.
    export async function handleRunUnitTest(
      context: HandlerContext,
      args: RunUnitTestArgs,
    ) {
      const { connection, logger } = context;
      try {
        const {
          tests,
          title,
          context: contextStr,
          scope,
          risk_level,
          duration,
        } = args as RunUnitTestArgs;
    
        // Validation
        if (!Array.isArray(tests) || tests.length === 0) {
          return return_error(
            new Error('tests array with at least one entry is required'),
          );
        }
    
        // Format tests for AdtClient
        const formattedTests = tests.map((test) => ({
          containerClass: test.container_class.toUpperCase(),
          testClass: test.test_class.toUpperCase(),
        }));
    
        const client = createAdtClient(connection, logger);
        const unitTest = client.getUnitTest();
    
        logger?.info(
          `Starting ABAP Unit run for ${formattedTests.length} test definition(s)`,
        );
    
        try {
          // Create test run using AdtClient
          const createResult = await unitTest.create({
            tests: formattedTests,
            options: {
              title,
              context: contextStr,
              scope: scope
                ? {
                    ownTests: scope.own_tests,
                    foreignTests: scope.foreign_tests,
                    addForeignTestsAsPreview: scope.add_foreign_tests_as_preview,
                  }
                : undefined,
              riskLevel: risk_level,
              duration,
            },
          });
    
          if (!createResult.runId) {
            throw new Error('Failed to start unit test run: run_id not returned');
          }
    
          logger?.info(`✅ RunUnitTest started. Run ID: ${createResult.runId}`);
    
          return return_response({
            data: JSON.stringify(
              {
                success: true,
                run_id: createResult.runId,
                message: `ABAP Unit run started. Use GetUnitTest with run_id ${createResult.runId} to get status and results.`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(`Error starting ABAP Unit run: ${error?.message || error}`);
          return return_error(new Error(error?.message || String(error)));
        }
      } catch (error: any) {
        return return_error(error);
      }
    }
  • TOOL_DEFINITION export containing the RunUnitTest name, inputSchema with tests array (container_class, test_class), title, context, scope, risk_level, and duration properties.
    export const TOOL_DEFINITION = {
      name: 'RunUnitTest',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        'Start an ABAP Unit test run for provided class test definitions. Returns run_id for status/result queries.',
      inputSchema: {
        type: 'object',
        properties: {
          tests: {
            type: 'array',
            description: 'List of container/test class pairs to execute.',
            items: {
              type: 'object',
              properties: {
                container_class: {
                  type: 'string',
                  description:
                    'Class that owns the test include (e.g., ZCL_MAIN_CLASS).',
                },
                test_class: {
                  type: 'string',
                  description:
                    'Test class name inside the include (e.g., LTCL_MAIN_CLASS).',
                },
              },
              required: ['container_class', 'test_class'],
            },
          },
          title: {
            type: 'string',
            description: 'Optional title for the ABAP Unit run.',
          },
          context: {
            type: 'string',
            description: 'Optional context string shown in SAP tools.',
          },
          scope: {
            type: 'object',
            properties: {
              own_tests: { type: 'boolean' },
              foreign_tests: { type: 'boolean' },
              add_foreign_tests_as_preview: { type: 'boolean' },
            },
          },
          risk_level: {
            type: 'object',
            properties: {
              harmless: { type: 'boolean' },
              dangerous: { type: 'boolean' },
              critical: { type: 'boolean' },
            },
          },
          duration: {
            type: 'object',
            properties: {
              short: { type: 'boolean' },
              medium: { type: 'boolean' },
              long: { type: 'boolean' },
            },
          },
        },
        required: ['tests'],
      },
    } as const;
  • Registration of RunUnitTest tool in HighLevelHandlersGroup with toolDefinition and handler.
    {
      toolDefinition: RunUnitTest_Tool,
      handler: withContext(handleRunUnitTest),
    },
  • Compact handler that delegates to handleRunUnitTest.
    export async function handleHandlerUnitTestRun(
      context: HandlerContext,
      args: HandlerUnitTestRunArgs,
    ) {
      return handleRunUnitTest(context, args);
    }
  • Compact schema for unit test run (compactUnitTestRunSchema) used by HandlerUnitTestRun tool.
    export const compactUnitTestRunSchema = {
      type: 'object',
      properties: {
        tests: {
          type: 'array',
          description: 'List of test classes to run.',
          items: {
            type: 'object',
            properties: {
              container_class: {
                type: 'string',
                description: 'Productive class containing tests.',
              },
              test_class: { type: 'string', description: 'Local/unit test class.' },
            },
            required: ['container_class', 'test_class'],
          },
        },
        title: {
          type: 'string',
          description: 'Run title shown in ABAP Unit logs.',
        },
        context: { type: 'string', description: 'Run context label.' },
        scope: {
          type: 'object',
          description: 'ABAP Unit scope flags.',
          properties: {
            own_tests: { type: 'boolean', description: 'Include own tests.' },
            foreign_tests: {
              type: 'boolean',
              description: 'Include foreign tests.',
            },
            add_foreign_tests_as_preview: {
              type: 'boolean',
              description: 'Preview foreign tests without full inclusion.',
            },
          },
        },
        risk_level: {
          type: 'object',
          description: 'Allowed risk levels.',
          properties: {
            harmless: { type: 'boolean', description: 'Allow harmless tests.' },
            dangerous: { type: 'boolean', description: 'Allow dangerous tests.' },
            critical: { type: 'boolean', description: 'Allow critical tests.' },
          },
        },
        duration: {
          type: 'object',
          description: 'Allowed duration classes.',
          properties: {
            short: { type: 'boolean', description: 'Allow short tests.' },
            medium: { type: 'boolean', description: 'Allow medium tests.' },
            long: { type: 'boolean', description: 'Allow long tests.' },
          },
        },
      },
      required: ['tests'],
    } as const;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must disclose behavioral traits. It mentions returning run_id but does not indicate side effects (e.g., test execution may modify data), authorization needs, or that the run is asynchronous. Insufficient context for a mutation-like tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences with no filler. Front-loaded with key action and return value. Every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (6 params, nested objects, no output schema) and many sibling tools, the description lacks essential completeness. It does not explain asynchronous behavior, how to use run_id, or the meaning of scope/risk_level/duration.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50% (3 of 6 parameters described). The tool description adds no additional meaning for the undocumented parameters (scope, risk_level, duration). Baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the action (start), resource (ABAP Unit test run), and return value (run_id). It distinguishes from sibling tools like CreateUnitTest or GetUnitTest which have different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives (e.g., CreateUnitTest for defining tests, GetUnitTestResult for retrieving results). Usage is implied but not clarified.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fr0ster/mcp-abap-adt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server