Skip to main content
Glama

instrumentedTest

Run instrumented tests for Android projects to verify app behavior on devices or emulators. Specify the project folder path to execute tests that interact with the Android framework.

Instructions

Run instrumented test for the Android project in the folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYesThe full path of the current folder that the Android project sits

Implementation Reference

  • The shared handler function for all tools, including 'instrumentedTest', which parses arguments, sets the command to run 'instrumentedTest.sh', executes it via subprocess, and processes output to extract errors or success message.
    @server.call_tool() async def call_tool(name, arguments: dict) -> list[TextContent]: try: args = Folder(**arguments) except ValueError as e: raise McpError(ErrorData(code=INVALID_PARAMS, message=str(e))) # os.chdir(args.folder) script_dir = os.path.dirname(os.path.abspath(__file__)) command = [""] if name == "build": command = [os.path.join(script_dir, "build.sh"), args.folder] elif name == "test": command = [os.path.join(script_dir, "test.sh"), args.folder] else: command = [os.path.join(script_dir, "instrumentedTest.sh"), args.folder] result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False) stdout_lines = result.stdout.decode("utf-8").splitlines() stderr_lines = result.stderr.decode("utf-8").splitlines() all_lines = stdout_lines + stderr_lines error_lines = [line for line in all_lines if "failure: " in line.lower() or "e: " in line.lower() or " failed" in line.lower()] error_message = "\n".join(error_lines) if not error_message: error_message = "Successful" return [ TextContent(type="text", text=f"{error_message}") ]
  • Registration of the 'instrumentedTest' tool in the list_tools() function, specifying name, description, and input schema.
    Tool( name="instrumentedTest", description="Run instrumented test for the Android project in the folder", inputSchema=Folder.model_json_schema(), )
  • Pydantic BaseModel defining the input parameters for the 'instrumentedTest' tool (and others), consisting of a single 'folder' field.
    class Folder(BaseModel): """Parameters""" folder: Annotated[str, Field(description="The full path of the current folder that the Android project sits")]
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/ShenghaiWang/androidbuild'

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