# Test Command

Run test suites for Homeboy components/modules.

## Synopsis

```bash
homeboy test <component> [options]
```

## Description

The `test` command executes test suites for specified Homeboy components. It automatically discovers and runs the appropriate test infrastructure for each component type.

## Arguments

- `<component>`: Name of the component/module to test (must exist in `homeboy-modules/`)

## Options

- `--skip-lint`: Skip linting before running tests
- `--setting <key=value>`: Override component settings (can be used multiple times)

## Examples

```bash
# Test the wordpress component with default settings
homeboy test wordpress

# Test wordpress with MySQL instead of SQLite
homeboy test wordpress --setting database_type=mysql --setting mysql_host=localhost

# Run tests only, skip linting
homeboy test wordpress --skip-lint

# Test with multiple setting overrides
homeboy test wordpress --setting database_type=mysql --setting mysql_database=test_db
```

## Passthrough Arguments

Arguments after `--` are passed directly to the module's test runner script:

```bash
# Pass a single argument
homeboy test my-module -- --filter=SomeTest

# Pass multiple arguments
homeboy test my-module -- --filter=SomeTest --verbose
```

Supported arguments depend on the underlying test framework.

## Component Requirements

For a component to be testable, it must have:

- A directory in `homeboy-modules/{component}/`
- A `{component}.json` manifest file
- A `scripts/test-runner.sh` executable script

## Supported Components

Currently supported:

- **wordpress**: PHPUnit-based WordPress testing with SQLite/MySQL support

## Settings

Settings vary by component. For WordPress:

- `database_type`: `"sqlite"` (default) or `"mysql"`
- `mysql_host`: MySQL hostname (default: `"localhost"`)
- `mysql_database`: MySQL database name (default: `"wordpress_test"`)
- `mysql_user`: MySQL username (default: `"root"`)
- `mysql_password`: MySQL password (default: `""`)

## Output

Returns JSON with test results:

```json
{
  "status": "passed|failed",
  "component": "component-name",
  "output": "test output...",
  "exit_code": 0
}
```

## Exit Codes

- `0`: Tests passed
- `1`: Tests failed
- `2`: Infrastructure error (component not found, missing scripts, etc.)

## Environment Variables

The following environment variables are set for test runners:

- `HOMEBOY_EXEC_CONTEXT_VERSION`: Protocol version (`"1"`)
- `HOMEBOY_MODULE_ID`: Component name
- `HOMEBOY_MODULE_PATH`: Absolute path to module directory
- `HOMEBOY_PROJECT_PATH`: Absolute path to project directory
- `HOMEBOY_COMPONENT_ID`: Component identifier
- `HOMEBOY_COMPONENT_PATH`: Absolute path to component directory
- `HOMEBOY_SETTINGS_JSON`: Merged settings as JSON string

## Notes

- Tests run in the component's environment, not the project's
- SQLite provides fastest in-memory testing
- MySQL testing requires a running MySQL server
- Component settings can be configured globally via `homeboy config`