Skip to main content
Glama

Run unit tests

gradle_test

Runs Android unit tests for a module or filter, then returns pass/fail counts and each failure with message and file:line from Gradle test-result XML.

Instructions

Runs unit tests for a module (optionally filtered) and returns pass/fail counts plus each failure with message and file:line, read from build/test-results XML.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "projectDir": "<projectDir>"
    },
    "name": "gradle_test"
  }
}

Input Schema

NameRequiredDescriptionDefault
taskNoDefault "testDebugUnitTest"
filterNo--tests pattern, e.g. "com.foo.BarTest" or "*Login*"
moduleNoGradle module path, default ":app"
projectDirYesAbsolute path to the Android project (gradlew is searched upwards)
maxFailuresNoDefault 15

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.1

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare the safety profile (readOnlyHint=false, destructiveHint=false, openWorldHint=false). The description adds genuinely useful behavior beyond them by explaining that results are parsed from build/test-results XML and what each failure contains, but it omits cost/side-effect context such as the run being a long gradlew invocation that writes to the build directory, and it does not say whether failing tests surface as an error or a normal result.

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?

A single front-loaded sentence where every clause carries information: what runs, the optional filter, and the exact shape of the return value. Nothing is repeated from the schema or wasted.

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

Completeness4/5

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

With no output schema, the description correctly takes on the burden of describing returns (counts plus per-failure message and file:line), which is the key gap it fills. What is missing is failure-mode semantics: whether non-zero test results raise an error and how maxFailures truncates the reported list.

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 coverage is 100%, so every parameter (task, filter, module, projectDir, maxFailures) is already documented with defaults and examples. The description only echoes the filtering option via '(optionally filtered)' and adds no syntax or interpretation guidance beyond the schema, so the baseline of 3 applies.

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?

Names a specific verb and resource ('Runs unit tests for a module') and even sketches the return payload (pass/fail counts, failures with message and file:line). It is implicitly distinct from gradle_build, but it never names a sibling or states the boundary explicitly.

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?

Usage is only implied by the phrase 'optionally filtered' and the word 'test'; there is no statement of when to prefer this over gradle_build or gradle_tasks, and no exclusions or prerequisites. An agent can infer the intent but gets no routing guidance.

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