Skip to main content
Glama

CreateCdsUnitTest

Create a CDS unit test class with validation for a specified CDS view, including initial test double setup for unit testing.

Instructions

Create a CDS unit test class with CDS validation. Creates the test class in initial state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
class_nameYesGlobal test class name (e.g., ZCL_CDS_TEST).
package_nameYesPackage name (e.g., ZOK_TEST_PKG_01, $TMP).
cds_view_nameYesCDS view name to validate for unit test doubles.
descriptionNoOptional description for the global test class.
transport_requestNoTransport request number (required for transportable packages).

Implementation Reference

  • Main handler function for CreateCdsUnitTest MCP tool. Uses AdtClient.getCdsUnitTest().create() to create a CDS unit test class with ADT lifecycle (validate + create). Extracts args (class_name, package_name, cds_view_name, etc.), validates required params, calls the ADT client, and returns a JSON stringified response with test class state.
    export async function handleCreateCdsUnitTest(
      context: HandlerContext,
      args: CreateCdsUnitTestArgs,
    ) {
      const { connection, logger } = context;
      try {
        const {
          class_name,
          package_name,
          cds_view_name,
          class_template,
          test_class_source,
          description,
          transport_request,
        } = args as CreateCdsUnitTestArgs;
    
        if (!class_name || !package_name || !cds_view_name) {
          return return_error(
            new Error(
              'Missing required parameters: class_name, package_name, cds_view_name',
            ),
          );
        }
    
        const className = class_name.toUpperCase();
        const cdsViewName = cds_view_name.toUpperCase();
    
        const client = createAdtClient(connection, logger);
        const cdsUnitTest = client.getCdsUnitTest();
    
        logger?.info(
          `Creating CDS unit test class ${className} for CDS view ${cdsViewName}`,
        );
    
        try {
          const createResult = await cdsUnitTest.create({
            className,
            packageName: package_name,
            cdsViewName,
            classTemplate: class_template || '',
            testClassSource: test_class_source || '',
            description,
            transportRequest: transport_request,
          });
    
          if (!createResult?.testClassState) {
            throw new Error(
              `Create did not return a response for CDS unit test class ${className}`,
            );
          }
    
          logger?.info(`✅ CreateCdsUnitTest completed successfully: ${className}`);
    
          // Extract safe fields — testClassState contains AxiosResponse objects
          // with circular references that cannot be JSON.stringified
          const safeState = {
            testClassCode: createResult.testClassState?.testClassCode,
            lockHandle: createResult.testClassState?.lockHandle,
            errors: createResult.testClassState?.errors,
          };
    
          return return_response({
            data: JSON.stringify(
              {
                success: true,
                class_name: className,
                cds_view_name: cdsViewName,
                test_class_state: safeState,
                message: `CDS unit test class ${className} created successfully.`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error creating CDS unit test class ${className}: ${error?.message || error}`,
          );
          return return_error(new Error(error?.message || String(error)));
        }
      } catch (error: any) {
        return return_error(error);
      }
    }
  • Tool definition/schema for CreateCdsUnitTest. Defines name 'CreateCdsUnitTest', availability ('onprem', 'cloud', 'legacy'), description, and inputSchema with properties: class_name (string), package_name (string), cds_view_name (string), description (optional string), transport_request (optional string). Required fields: class_name, package_name, cds_view_name.
    export const TOOL_DEFINITION = {
      name: 'CreateCdsUnitTest',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        'Create a CDS unit test class with CDS validation. Creates the test class in initial state.',
      inputSchema: {
        type: 'object',
        properties: {
          class_name: {
            type: 'string',
            description: 'Global test class name (e.g., ZCL_CDS_TEST).',
          },
          package_name: {
            type: 'string',
            description: 'Package name (e.g., ZOK_TEST_PKG_01, $TMP).',
          },
          cds_view_name: {
            type: 'string',
            description: 'CDS view name to validate for unit test doubles.',
          },
          description: {
            type: 'string',
            description: 'Optional description for the global test class.',
          },
          transport_request: {
            type: 'string',
            description:
              'Transport request number (required for transportable packages).',
          },
        },
        required: ['class_name', 'package_name', 'cds_view_name'],
      },
    } as const;
  • Registration of CreateCdsUnitTest in HighLevelHandlersGroup. Maps the CreateCdsUnitTest_Tool (imported from handleCreateCdsUnitTest.ts) to the handler wrapped with withContext(handleCreateCdsUnitTest).
    {
      toolDefinition: CreateCdsUnitTest_Tool,
      handler: withContext(handleCreateCdsUnitTest),
    },
  • Import of CreateCdsUnitTest tool definition (renamed to CreateCdsUnitTest_Tool) and handler from '../../../handlers/unit_test/high/handleCreateCdsUnitTest'.
    import {
      TOOL_DEFINITION as CreateCdsUnitTest_Tool,
      handleCreateCdsUnitTest,
    } from '../../../handlers/unit_test/high/handleCreateCdsUnitTest';
  • Registration of handleCreateCdsUnitTest in compact router for CDS_UNIT_TEST object type under the 'create' CRUD operation.
    CDS_UNIT_TEST: {
      create: handleCreateCdsUnitTest as unknown as CompactHandler,
Behavior2/5

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

No annotations are present, so the description carries full burden. It mentions 'creates in initial state,' which hints at behavior but lacks details on side effects, permissions, or what happens if the class already exists. For a creation tool, more disclosure is needed.

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?

The description is two sentences, front-loading the purpose and adding a concise behavioral hint. No redundancy or fluff; every sentence earns its place.

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 absence of output schema and annotations, the description should provide more context on return values, error conditions, or what 'initial state' means. For a creation tool with 5 parameters, it lacks completeness about the tool's full behavior.

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 100%, so the description does not add meaning beyond the input schema. Each parameter is described in the schema, and the description offers no additional semantics, resulting in a baseline score of 3.

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?

The tool name 'CreateCdsUnitTest' and description 'Create a CDS unit test class with CDS validation. Creates the test class in initial state.' clearly state the specific action and resource. It distinguishes from sibling tools like CreateUnitTest and DeleteCdsUnitTest by focusing on CDS test class creation.

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?

The description provides no guidance on when to use this tool versus alternatives (e.g., CreateUnitTest), no context on prerequisites or when not to use it. The agent must infer usage from the name alone, which is insufficient given many sibling tools.

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