File Import Export - sebiboga/testlink-upgraded GitHub Wiki
Complete guide to TestLink file import/export functionality with real-world examples.
TestLink supports importing and exporting data in XML format. This enables:
- Data Exchange - Move data between TestLink instances
- Bulk Operations - Import/export large datasets
- Integration - Connect with external systems
- Backup & Restore - Preserve test data
- Automation - Programmatic data management
| Format | Purpose | Support | File Extension |
|---|---|---|---|
| XML | General data exchange | Full | .xml |
| CSV | Test results | Partial | .csv |
| JSON | REST API | Full | .json |
Complete documentation and examples in docs/file_examples/:
- README.md - Comprehensive format specifications
- custom_fields/ - Custom field definitions
- keywords/ - Keyword organization
- platforms/ - Testing environments
- requirements/ - Requirement specifications
- testplan/ - Test plan definitions
- testspec/ - Test case specifications
- results/ - Test execution results
- xxe-attack/ - Security demonstrations (XXE)
What: Test cases, test suites, and test hierarchies
Format: XML
Includes:
- Test case metadata (name, description, status)
- Test steps with actions and expected results
- Keywords and custom fields
- Version information
- Author and timestamp data
Example:
<testcase>
<id>1</id>
<name>Login Test</name>
<description>Verify user login</description>
<steps>
<step>
<step_number>1</step_number>
<actions>Enter username</actions>
<expected_results>Field accepts input</expected_results>
</step>
</steps>
</testcase>What: Execution results and test outcomes
Format: XML
Includes:
- Test case and plan references
- Pass/fail/blocked/wait status
- Execution timestamp and tester
- Execution notes
- Bug associations
Status Codes:
-
p= PASSED -
f= FAILED -
b= BLOCKED -
w= WAIT
Example:
<execution>
<testcase_id>1</testcase_id>
<plan_id>1</plan_id>
<status>p</status>
<execution_ts>2024-08-16 10:30:00</execution_ts>
<notes>Test passed</notes>
</execution>What: Requirement specifications with traceability
Format: XML
Includes:
- Requirement ID and title
- Description and status
- Author and version
- Custom fields
- Test case linkage
Example:
<requirement>
<doc_id>REQ-001</doc_id>
<title>User Authentication</title>
<description>System shall support user login</description>
<status>accepted</status>
<version>1.0</version>
</requirement>What: Additional metadata fields
Format: XML
Types:
- Text input
- Dropdown/select
- Checkbox (boolean)
- Multi-select
Example:
<field>
<name>priority</name>
<label>Test Priority</label>
<type>dropdown</type>
<possible_values>Critical,High,Medium,Low</possible_values>
<default_value>Medium</default_value>
<enable_on_testcase>1</enable_on_testcase>
</field>What: Tags for test organization
Format: XML
Example:
<keyword>
<text>smoke</text>
<description>Smoke testing</description>
</keyword>What: Testing environments
Format: XML
Example:
<platform>
<name>Windows 10</name>
<notes>Windows 10 Enterprise</notes>
<is_active>1</is_active>
</platform>Steps:
- Navigate: Project → Test Specification → Import
- Select:
testspec.xmlfile - Configure: Field mapping and options
- Validate: Check for errors
- Execute: Confirm and process
Options:
- Create new or update existing
- Platform assignment
- Custom field mapping
- Duplicate handling
Steps:
- Navigate: Test Plan → Results → Import
- Select:
results.xmlfile - Map: Columns to test data
- Validate: Data integrity
- Execute: Import results
Requirements:
- Test plan must exist
- Test cases must be linked
- Status codes must be valid
Steps:
- Navigate: Requirement Management → Import
- Select:
requirements.xmlfile - Configure: Requirement spec settings
- Map: Fields and versions
- Execute: Import
Steps:
- Navigate: Project → Test Specification → Export
- Select: Items to export (suites or cases)
- Options: Include steps, custom fields, keywords
- Save: As
testspec.xml
Includes:
- Test hierarchy
- All steps
- Custom field values
- Keywords
Steps:
- Navigate: Test Plan → Results → Export
- Select: Date range or executions
- Options: Include notes, bugs, custom fields
- Format: Select XML
- Save: As
results.xml
Steps:
- Navigate: Requirements → Export
- Select: Requirement specs
- Include: Custom fields, traceability
- Save: As
requirements.xml
Required fields:
-
name- Max 255 characters -
description- Optional, max 2000 characters - Steps must have:
-
actions- What to do -
expected_results- Expected outcome
-
Valid values:
-
status- active, frozen -
execution_type- manual, automated -
keywords- Must exist in system
Required fields:
-
testcase_id- Must reference valid test case -
plan_id- Must reference valid test plan -
build_id- Must reference valid build -
status- Must be p, f, b, or w -
execution_ts- Valid timestamp
Required fields:
-
doc_id- Unique identifier -
title- Max 500 characters -
status- draft, accepted, review, deprecated -
version- Numeric version
| Error | Cause | Solution |
|---|---|---|
| XML Parse Error | Malformed XML | Validate with xmllint
|
| Invalid Field Type | Unknown type | Check allowed types |
| Duplicate ID | Already exists | Use update mode |
| Missing Required | Required field absent | Add all required fields |
| Invalid Status | Invalid status code | Use valid status values |
| Reference Error | ID doesn't exist | Verify referenced IDs |
Check XML Validity:
xmllint --noout file.xmlPretty Print XML:
xmllint --format file.xmlValidate Against DTD:
xmllint --dtdvalid schema.dtd file.xmlVulnerability: XXE attacks can expose files or cause DoS
Examples: See docs/file_examples/xxe-attack/
Prevention:
- Disable external entities
- Validate before import
- Use whitelist for entities
- Update XML libraries
- Limit file sizes
Safe Parsing (PHP):
libxml_disable_entity_loader(true);
$xml = simplexml_load_file('file.xml');- Sanitize input - Clean imported data
- Validate IDs - Ensure references exist
- Encrypt exports - For sensitive data
- Access control - Restrict import/export
- Audit log - Track operations
- Backup first - Before large imports
<?xml version="1.0" encoding="UTF-8"?>
<testcase>
<id>1</id>
<name>Login Test</name>
<description>Verify user login</description>
<execution_type>manual</execution_type>
<status>active</status>
</testcase><?xml version="1.0" encoding="UTF-8"?>
<testcase>
<id>2</id>
<name>Login with Valid Credentials</name>
<steps>
<step>
<step_number>1</step_number>
<actions>Enter username</actions>
<expected_results>Field accepts input</expected_results>
</step>
<step>
<step_number>2</step_number>
<actions>Click login</actions>
<expected_results>User logged in</expected_results>
</step>
</steps>
</testcase><?xml version="1.0" encoding="UTF-8"?>
<execution>
<testcase_id>1</testcase_id>
<plan_id>1</plan_id>
<status>p</status>
<execution_ts>2024-08-16 10:30:00</execution_ts>
<notes>Test passed successfully</notes>
</execution>#!/bin/bash
API_TOKEN="your_token"
BASE_URL="https://testlink/api/rest/v3"
# Import test specification
curl -X POST "$BASE_URL/import/testspec" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/xml" \
-d @testspec.xml
# Export test results
curl -X GET "$BASE_URL/export/results/1" \
-H "Authorization: Bearer $API_TOKEN" \
> results.xmlimport requests
import xml.etree.ElementTree as ET
API_TOKEN = "your_token"
BASE_URL = "https://testlink/api/rest/v3"
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Accept": "application/xml"
}
# Export test cases
response = requests.get(f"{BASE_URL}/export/testspec/1",
headers=headers)
with open('testspec.xml', 'w') as f:
f.write(response.text)
# Parse XML
root = ET.fromstring(response.text)
for testcase in root.findall('testcase'):
name = testcase.find('name').text
print(f"Test Case: {name}")- Backup - Always backup existing data
- Validate - Check XML validity
- Test - Import to development first
- Map Fields - Ensure correct mapping
- Verify - Check data integrity
- Monitor - Watch for errors
- Small Batches - Import in parts for large datasets
- Verify Progress - Check imported counts
- Review Errors - Address validation issues
- Log Operations - Keep import records
- Verify - Check imported data
- Test - Run test execution
- Compare - Compare with original
- Document - Note what was imported
- Archive - Keep export files
- Single File: 50 MB max
- Batch Import: 500 MB total
- Test Cases: 10,000 max per file
- Results: 50,000 max per file
- Split Large Files - Import in batches
- Disable Indexing - Temporarily during import
- Increase Timeout - For large files
- Check Resources - Monitor memory/CPU
- Optimize Server - For better performance
Check:
- XML validity:
xmllint --noout file.xml - Character encoding: Must be UTF-8
- File permissions: Must be readable
- Field mapping: Correct references
- Error log: Check for details
Check:
- Field mapping configuration
- Data validation results
- User import permissions
- XML completeness
- Field data types
Solutions:
- Split into smaller files
- Disable indexing temporarily
- Increase timeout values
- Check server resources
- Optimize database
- Developer-Guide - Development guide
- API-Documentation - REST API reference
- Sample-Database - Sample data structure
- README.md - Complete format specifications
Version: TestLink 1.9.20
Last Updated: August 2026