MainworthyDocs Open Mainworthy

Import cases from CSV

Use a CSV file to bring cases into Mainworthy. Preview how the columns map to case content and project fields before you confirm the import.

Use mainworthy import-csv or the same import-csv operation through HTTP. On the project, you need produce, which lets you write and edit cases, report results, review, and send answers. It includes record, which lets you report results and attachments and say that a change ended or a deployment happened. Mapped CSV import is available through the CLI and HTTP.

Preview the file #

The file can contain up to 5,000 cases and occupy up to 8 MiB. Each CSV record describes one case. Quoted cells can contain commas, doubled quotes, and line breaks. A multiline steps cell becomes one action block.

  1. Save the file as UTF-8 CSV with a header row.
  2. Give each case its ID from the source tool and a title.
  3. Map each Mainworthy field you want to fill to a CSV column header.
  4. Run mainworthy import-csv with that mapping.

For a file with Source ID, Name, Action, Result, and Path headers, use this command:

mainworthy import-csv cases.csv --project checkout \
    --mapping '{"id":"Source ID","title":"Name","steps":"Action","expected":"Result","folder":"Path"}' \
    --json

The reply shows each record's alias, folder, case content, and any reason Mainworthy refuses it. An alias is the source ID you can use to look up the imported case. create counts valid records and refused counts invalid records. If Mainworthy refuses a record, its body is null.

The preview advances the project's sequence number, which tracks its writes. If you supply cmd, Mainworthy saves the preview receipt under that command ID like other write operations. The preview creates no cases, folders, proposals, or decisions.

If Mainworthy refuses any record, confirmation is null and you must fix every refused record before importing. Mainworthy rejects the preview request if CSV quoting is invalid, a mapped column is missing, the file is empty, or a header is invalid.

Map project fields #

Optional mapping keys are pre, steps, expected, folder, and execution. An absent or empty folder becomes Unsorted. Folder values are paths such as Checkout/Coupons. A title must contain 1 to 300 characters. If you map an expected result, supply its step action too.

Use fields to map your project's custom field keys to source columns:

{"id":"ID","title":"Title","fields":{"priority":"Priority","risk":"Risk notes"}}

Create the field definitions in Settings, Policy, under Custom fields before importing. The importer refuses a record with a missing field definition, an invalid choice, or a missing required value. Define each field and its allowed values before you map it. The importer ignores columns you leave unmapped, including source history and dates.

The execution column sets how to run the case and whether you intend to automate it. The values manual and human select the human method. automated and auto select auto. to-be-automated selects human with wanted intent. The value wanted has the same effect. not-applicable selects human with not-applicable intent. An empty value, none, or is-not-automated selects human with no automation intent. The importer refuses unknown values.

Confirm the reviewed import #

  1. Review the full preview reply.
  2. Choose a new command ID for the confirmed request.
  3. Repeat the same file and mapping with the returned confirmation value and the new command ID.

For example, use this command:

mainworthy import-csv cases.csv --project checkout \
    --mapping '{"id":"Source ID","title":"Name","steps":"Action","expected":"Result","folder":"Path"}' \
    --confirm 012345abcdef --cmd import-checkout-001 --json

Replace 012345abcdef with the value your preview returned. A changed file, mapping, preset, or policy requires another preview. The server checks aliases and field values again inside the confirmed transaction.

Mainworthy records the confirmed import as separate proposals of up to 200 cases each, in one transaction. Each proposal applies in full or changes nothing. If a proposal stays open for review or Mainworthy refuses it, the remaining proposals can still apply.

The project's policy sets who answers each kind of question and which answers count. For each proposal, the policy either accepts it immediately or asks for acceptance in the queue. An open proposal has yet to create any cases. The proposals list includes a reply for every proposal, including refusals. For each successful reply, check result.status, result.question, and result.needs. If the import has one successful proposal and no others, the reply also gives its result in proposal. Otherwise proposal is null.

Mainworthy uses the source ID as the case alias. For example, mainworthy get C1234 and tests annotated with @C1234 resolve to the imported case. For alias rules, see Your data. Mainworthy refuses existing aliases and duplicate IDs within the file. If you reimport a case with the same alias, Mainworthy keeps the existing case and any edits you made after the first import.

If the reply to a confirmed request is lost, retry with the same input and cmd to get its recorded receipt. If you reuse cmd with different input, Mainworthy returns a conflict. Use separate IDs for the preview and the confirmed import.

The file command exits with code 2 if Mainworthy refuses a record or a proposal awaits acceptance, with or without --json. The generated --json '<input JSON>' operation form prints the full reply. Check its refused count and proposal.status yourself.

Use the TestRail preset #

TestRail's export documentation links a CSV sample with ID, Title, Section, Section Depth, Type, and Steps (Expected Result) headers. Preview that format with:

mainworthy import-csv testrail.csv --preset testrail --json

If the file has step, expected result, or precondition columns, the preset reads them. Automation Type takes precedence over Type. Type equal to Automated or Manual selects its execution method. Other testing types keep human. Supply a complete --mapping with the preset to select custom fields such as priority. Without a custom mapping, the preset ignores priority and other extra columns.

Section Depth reconstructs nested paths in source order. Each parent section needs a row. An empty parent section has no case row, so the export cannot name it. Before confirming, inspect the preview's folder paths.

This preset accepts one record per case. If the file puts steps on separate rows, the preset refuses those rows as missing or duplicate IDs. For the existing importer that joins TestRail's separate-row steps and retains every source row, see case snapshots in Your data. That importer has no preview for column mappings.

Call the operation directly #

  1. Send POST /api/p/<project>/import-csv with the file text in csv and no confirm value. Include the column mapping in mapping, or use preset: "testrail".
  2. Review the preview reply.
  3. Send the same input with the returned confirmation in confirm.

The generated CLI form is mainworthy import-csv --json '<input JSON>'. See the API reference for authentication and reply envelopes.

Mainworthy 0.1.0 · Licence · this page is docs/guide/import-cases.md in the repository