TEST_INFRASTRUCTURE.mdā¢6.68 kB
# Test Infrastructure Update - Summary
## šÆ Overview
Implemented YAML-based test configuration system to centralize test parameters across all MCP ABAP ADT handlers. This eliminates the need for hardcoded test values and makes it easy to update environment-specific settings (especially transport requests).
## ā
What Was Done
### 1. Created Test Infrastructure
**`tests/test-config.yaml`** - Central test configuration
- Defines test cases for each handler (create_domain, get_class, get_table, etc.)
- Each test case has: name, enabled flag, description, and parameters
- Easy to enable/disable specific tests
- Clear markers (ā ļø) for values that must be updated before testing
**`tests/test-helper.js`** - Reusable test utilities
- `getEnabledTestCase(handlerName)` - Load test from YAML
- `printTestHeader()` - Formatted test banners
- `printTestParams()` - Pretty-print parameters
- `printTestResult()` - Parse and display results
- `validateTransportRequest()` - Warn about default values
- `waitForConfirmation()` - Countdown before destructive operations
**`tests/run-all-tests.js`** - Universal test runner
- Run all enabled tests: `node tests/run-all-tests.js`
- Run specific handler: `node tests/run-all-tests.js create_domain`
- List all tests: `node tests/run-all-tests.js --list`
- Supports fail-fast, verbose output, and retry settings
### 2. Updated Test Scripts
Migrated the following tests to use YAML config:
- ā
`test-create-domain.js` - New CreateDomain handler test
- ā
`test-get-class.js` - Class retrieval
- ā
`test-get-table.js` - Table structure
- ā
`test-get-table-contents.js` - Table data
- ā
`test-search-object.js` - Object search
- ā
`test-get-sql-query.js` - SQL queries
All updated tests support:
- YAML configuration (default)
- Command-line override (for ad-hoc testing)
- Consistent output formatting
- Proper error handling
### 3. Documentation
**`tests/README.md`** - Updated with YAML-based testing guide
- Quick start instructions
- Test configuration structure
- Running tests (single, multiple, all)
- Adding new tests
- Troubleshooting
**`doc/CREATE_DOMAIN_TOOL.md`** - CreateDomain handler documentation
- Complete API reference
- Workflow steps (lock ā create ā check ā unlock ā activate ā verify)
- Session management architecture
- Input parameters and examples
- Error handling and limitations
## š File Structure
```
tests/
āāā test-config.yaml # ā Central test configuration
āāā test-helper.js # ā Common utilities
āāā run-all-tests.js # ā Universal test runner
āāā README.md # ā Updated testing guide
āāā test-create-domain.js # ā Uses YAML config
āāā test-get-class.js # ā Uses YAML config
āāā test-get-table.js # ā Uses YAML config
āāā test-get-table-contents.js # ā Uses YAML config
āāā test-search-object.js # ā Uses YAML config
āāā test-get-sql-query.js # ā Uses YAML config
āāā ... (other legacy tests)
doc/
āāā CREATE_DOMAIN_TOOL.md # ā New CreateDomain documentation
```
## š Usage Examples
### Update Test Configuration
Edit `tests/test-config.yaml`:
```yaml
create_domain:
test_cases:
- name: "basic_char_domain"
enabled: true
params:
domain_name: "ZZ_TEST_MCP_01"
transport_request: "E19K905999" # Your transport!
package_name: "ZOK_LOCAL"
```
### Run Tests
```bash
# Compile first
npm run build
# Run single test from YAML
node tests/test-create-domain.js
# Run with CLI override
node tests/test-get-class.js CL_ABAP_TYPEDESCR
# Run all enabled tests for a handler
node tests/run-all-tests.js create_domain
# Run all enabled tests
node tests/run-all-tests.js
# List available tests
node tests/run-all-tests.js --list
```
## šÆ Benefits
### Before (Hardcoded Values)
```javascript
const args = {
domain_name: 'ZZ_TEST_MCP_01',
transport_request: 'E19K905635', // ā Hardcoded, needs editing
package_name: 'ZOK_LOCAL'
};
```
### After (YAML Config)
```yaml
# tests/test-config.yaml
create_domain:
test_cases:
- name: "basic_test"
enabled: true
params:
domain_name: "ZZ_TEST_MCP_01"
transport_request: "E19K905635" # ā
One place to update
```
### Advantages
1. **Single Source of Truth**: All test parameters in one YAML file
2. **Easy Maintenance**: Update transport request once, affects all tests
3. **Enable/Disable**: Toggle tests without code changes
4. **Multiple Scenarios**: Define multiple test cases per handler
5. **CLI Override**: Still supports ad-hoc command-line testing
6. **Consistency**: Same helper functions across all tests
## š Migration Path for Other Tests
To migrate a legacy test:
1. Add test case to `tests/test-config.yaml`:
```yaml
my_handler:
test_cases:
- name: "test_case_name"
enabled: true
params:
param1: value1
```
2. Update test script:
```javascript
const { getEnabledTestCase, printTestResult } = require('./test-helper');
const testCase = getEnabledTestCase('my_handler');
const result = await handleMyHandler(testCase.params);
printTestResult(result, 'MyHandler');
```
3. Register in `tests/run-all-tests.js`:
```javascript
const HANDLER_MAP = {
'my_handler': () => require('../dist/handlers/handleMyHandler').handleMyHandler,
};
```
## š Next Steps
1. ā
Update `transport_request` in `test-config.yaml` before running create_domain tests
2. ā
Enable/disable test cases as needed
3. ā
Run `npm run build` before testing
4. ā
Test CreateDomain functionality on real SAP system
5. ā³ Migrate remaining legacy tests to YAML config (optional)
6. ā³ Add more test cases for edge scenarios
7. ā³ Integrate with CI/CD pipeline
## ā ļø Important Notes
- **Transport Requests**: Must be updated in YAML before running write operations
- **Environment**: Tests load `.env` file (default: `e19.env`)
- **Dependencies**: Run `npm install` (yaml package now installed)
- **Build**: Always run `npm run build` after code changes
- **Legacy Tests**: Old tests still work but don't use YAML config
## š Test Coverage
Current YAML-configured handlers:
- ā
create_domain
- ā
get_class
- ā
get_table
- ā
get_table_contents
- ā
get_package
- ā
search_object
- ā
get_sql_query
- ā
get_where_used
- ā
get_object_info
- ā
get_abap_ast
- ā
get_abap_semantic_analysis
Legacy tests (not yet migrated):
- test-get-program.js (uses spawn)
- test-enhancement-*.js (specialized tests)
- test-includes-*.js (specialized tests)
- ... and others