Repository navigation
MD Test Case Import
Endpoint: POST /api/testcasesimport/?action=import_md&tproject_id=<id>
Auth: TestLink session (cookie), permission mgt_modify_tc on target project
Parser: lib/functions/markdown_tc_import.class.php (pure parser, no DB access)
Format reference: tmp/TLU_Test_Cases.md
| Param | Where | Notes |
|---|---|---|
tproject_id |
query | target test project (falls back to session project) |
markdown |
form field | the MD text; OR multipart file field uploadedFile
|
dry_run |
query |
1 = parse + resolve + report, zero DB writes |
hit_criteria |
query |
name (default) | internalID | externalID — all accepted; only name implemented for MD |
action_on_hit |
query |
skip (default) | create_new_version | generate_new | update_last_version
|
Limits: payload larger than import_file_max_size_bytes → HTTP 413.
- Metadata header is parsed (
Project/Prefix/Author/Date). If the file names a different project than the target, response carriesprojectMismatch— caller decides. - Suites match by name (case-insensitive) anywhere in the project; missing ones are created under the project root.
- Cases duplicate by title within the target suite → skipped, new version created, or new TC created (see
action_on_hit). - Steps support
*Expected:*inline markers; importance mapped High/Medium/Low → 3/2/1. - Response reports per-item arrays:
created,skipped,newVersions,failed, plussuitesCreated,suitesMatched,parserErrors.
curl -b cookies.txt -X POST \
-F "markdown=@TLU_Test_Cases.md" \
"http://host/api/testcasesimport/?action=import_md&tproject_id=29&dry_run=1"
{"status":"ok","dry_run":true,"createdCount":120,"skippedCount":0,
"newVersionCount":0,"failedCount":0,"suitesCreated":["Header","Dashboard"],
"parserErrors":[],
"projectMismatch":{"file":"TLU: TestLink Upgraded 2.0.1","target":"MD Import Fixture"}}dry-run no-write · real create with external IDs · idempotent re-import · create_new_version doubles tcversions · generate_new creates new TC when name matches · full-file dry run (122 cases/24 suites) · 403 without rights · 413 over size limit · no Event Viewer pollution.
When a case matches an existing TC in the target suite (by hit_criteria):
-
skip— leave the existing TC untouched (added toskipped). -
create_new_version— bump to a fresh test case version, then update it (added tonewVersions; the human-readableversionnumber increments). -
update_last_version— resolve the latest version viaget_last_version_info()and update it in place (no new version); legacy parity withlib/testcases/tcImport.php:384-427. If the name matches no existing TC it falls through to create, matching legacycase 0. -
generate_new— bypass duplicate detection and always create a new TC (legacy parity:tcImport.php:274-276).
Same permission model and size cap; duplicate criteria limited to name
(legacy also has internalID/externalID); all four legacy actions supported
(skip, create_new_version, generate_new, update_last_version).
The import screen is modernized as a standalone HTML+JS+CSS page backed by the BFF above.
- ASIDE/Test Specification:
Test Cases > Import Test Cases(project root,lib/functions/common.php:1895) - Test Specification > containerView Import button (
containerView.tpl:41-44) - Test Suite text buttons Import (
containerViewTestSuiteTextButtons.inc.tpl:129, dashio + tl-classic)
-
File type selector XML (legacy form passthrough →
lib/testcases/tcImport.php) vs Markdown (.md) (BFF). - MD mode: dry-run toggle → PREVIEW report with created/skipped/duplicate tables, zero DB writes; project-mismatch banner when file header names another project.
- Duplicate hit criteria (name-only for MD) + action for duplicates (skip / create new version / generate new).
- Client-side size guard (toast at
import_file_max_size_bytes) before upload; server 413 backup. -
mgt_modify_tcgate: no-rights users see a lock notice and a disabled Upload button. - Mandatory i18n via
TLi18n— all labels keyed in every locale bundle.



Suite 63 in tmp/TLU_Test_Cases.md (11 test cases covering render, MD/XML toggle,
dry-run, real import + DB verify, idempotent re-import, project mismatch, oversize,
no-permission, XML passthrough, cancel, Event Viewer cleanliness).