Skip to main content
Glama

CreateUnitTest

Run ABAP Unit tests for specified container and test class pairs. Returns a run ID to query 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

  • The main handler function for CreateUnitTest. Creates an ADT client, formats test definitions, calls unitTest.create(), and returns the run_id.
    export async function handleCreateUnitTest(
      context: HandlerContext,
      args: CreateUnitTestArgs,
    ) {
      const { connection, logger } = context;
      try {
        const {
          tests,
          title,
          context: contextStr,
          scope,
          risk_level,
          duration,
        } = args as CreateUnitTestArgs;
    
        // Validation
        if (!Array.isArray(tests) || tests.length === 0) {
          return return_error(
            new Error('tests array with at least one entry is required'),
          );
        }
    
        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 {
          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(`✅ CreateUnitTest 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 (name, description, inputSchema) and TypeScript interface CreateUnitTestArgs defining the input parameters (tests, title, context, scope, risk_level, duration).
    export const TOOL_DEFINITION = {
      name: 'CreateUnitTest',
      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 CreateUnitTest_Tool and handleCreateUnitTest in the HighLevelHandlersGroup.
    {
      toolDefinition: CreateUnitTest_Tool,
      handler: withContext(handleCreateUnitTest),
  • Registration of handleCreateUnitTest as the 'create' handler for UNIT_TEST in the compact router.
    UNIT_TEST: {
      create: handleCreateUnitTest as unknown as CompactHandler,
      get: handleGetUnitTest as unknown as CompactHandler,
      update: handleUpdateUnitTest as unknown as CompactHandler,
      delete: handleDeleteUnitTest as unknown as CompactHandler,
Behavior2/5

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

No annotations provided. The description only says it starts a run and returns an ID, without disclosing side effects, authentication needs, or whether it is destructive/readonly.

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 sentences, concise and front-loaded. Every word is necessary and directly conveys the core functionality.

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

Completeness3/5

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

While it mentions the return of a run_id for status/result queries, it lacks details on optional parameters, typical usage patterns, and does not differentiate from similar sibling tools.

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

Parameters2/5

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

Schema description coverage is 50%, but the description adds no parameter details beyond the schema. It does not explain how to use optional parameters like scope, risk_level, or duration.

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

Purpose4/5

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

The description clearly states the verb 'Start' and resource 'ABAP Unit test run', and mentions returning a run_id. However, it does not distinguish from sibling tools like 'RunUnitTest', which may have similar purpose.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., RunUnitTest, CreateCdsUnitTest). The description lacks any 'when' or 'when not' context.

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