Skip to content

File Import Export

sebiboga edited this page Aug 16, 2026 · 1 revision

TestLink File Import/Export - Formats & Examples

Complete guide to TestLink file import/export functionality with real-world examples.

Overview

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

Supported Formats

Format Purpose Support File Extension
XML General data exchange Full .xml
CSV Test results Partial .csv
JSON REST API Full .json

Import/Export Resources

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)

Importable Data Types

Test Specifications

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>

Test Results

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>

Requirements

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>

Custom Fields

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>

Keywords

What: Tags for test organization

Format: XML

Example:

<keyword>
  <text>smoke</text>
  <description>Smoke testing</description>
</keyword>

Platforms

What: Testing environments

Format: XML

Example:

<platform>
  <name>Windows 10</name>
  <notes>Windows 10 Enterprise</notes>
  <is_active>1</is_active>
</platform>

Import Workflows

Importing Test Cases

Steps:

  1. Navigate: Project → Test Specification → Import
  2. Select: testspec.xml file
  3. Configure: Field mapping and options
  4. Validate: Check for errors
  5. Execute: Confirm and process

Options:

  • Create new or update existing
  • Platform assignment
  • Custom field mapping
  • Duplicate handling

Importing Test Results

Steps:

  1. Navigate: Test Plan → Results → Import
  2. Select: results.xml file
  3. Map: Columns to test data
  4. Validate: Data integrity
  5. Execute: Import results

Requirements:

  • Test plan must exist
  • Test cases must be linked
  • Status codes must be valid

Importing Requirements

Steps:

  1. Navigate: Requirement Management → Import
  2. Select: requirements.xml file
  3. Configure: Requirement spec settings
  4. Map: Fields and versions
  5. Execute: Import

Export Workflows

Exporting Test Specification

Steps:

  1. Navigate: Project → Test Specification → Export
  2. Select: Items to export (suites or cases)
  3. Options: Include steps, custom fields, keywords
  4. Save: As testspec.xml

Includes:

  • Test hierarchy
  • All steps
  • Custom field values
  • Keywords

Exporting Test Results

Steps:

  1. Navigate: Test Plan → Results → Export
  2. Select: Date range or executions
  3. Options: Include notes, bugs, custom fields
  4. Format: Select XML
  5. Save: As results.xml

Exporting Requirements

Steps:

  1. Navigate: Requirements → Export
  2. Select: Requirement specs
  3. Include: Custom fields, traceability
  4. Save: As requirements.xml

Data Validation

Test Cases

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

Test Results

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

Requirements

Required fields:

  • doc_id - Unique identifier
  • title - Max 500 characters
  • status - draft, accepted, review, deprecated
  • version - Numeric version

Import Error Handling

Common Errors

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

Validation Tools

Check XML Validity:

xmllint --noout file.xml

Pretty Print XML:

xmllint --format file.xml

Validate Against DTD:

xmllint --dtdvalid schema.dtd file.xml

Security Considerations

XXE (XML External Entity) Protection

Vulnerability: 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');

Data Protection

  • 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

File Format Examples

Simple Test Case

<?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>

Test Case with Steps

<?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>

Test Result

<?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>

Integration Examples

Bash Script

#!/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.xml

Python Script

import 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}")

Best Practices

Before Importing

  1. Backup - Always backup existing data
  2. Validate - Check XML validity
  3. Test - Import to development first
  4. Map Fields - Ensure correct mapping
  5. Verify - Check data integrity

During Import

  1. Monitor - Watch for errors
  2. Small Batches - Import in parts for large datasets
  3. Verify Progress - Check imported counts
  4. Review Errors - Address validation issues
  5. Log Operations - Keep import records

After Import

  1. Verify - Check imported data
  2. Test - Run test execution
  3. Compare - Compare with original
  4. Document - Note what was imported
  5. Archive - Keep export files

File Size Limits

  • Single File: 50 MB max
  • Batch Import: 500 MB total
  • Test Cases: 10,000 max per file
  • Results: 50,000 max per file

Performance Tips

  1. Split Large Files - Import in batches
  2. Disable Indexing - Temporarily during import
  3. Increase Timeout - For large files
  4. Check Resources - Monitor memory/CPU
  5. Optimize Server - For better performance

Troubleshooting

File Won't Import

Check:

  1. XML validity: xmllint --noout file.xml
  2. Character encoding: Must be UTF-8
  3. File permissions: Must be readable
  4. Field mapping: Correct references
  5. Error log: Check for details

Missing Data

Check:

  1. Field mapping configuration
  2. Data validation results
  3. User import permissions
  4. XML completeness
  5. Field data types

Slow Performance

Solutions:

  1. Split into smaller files
  2. Disable indexing temporarily
  3. Increase timeout values
  4. Check server resources
  5. Optimize database

Related Documentation


Version: TestLink 1.9.20
Last Updated: August 2026

Quick Links

Clone this wiki locally