Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions trcli/api/run_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,21 @@ def add_run(
include_all=include_all,
refs=refs,
)

# Validate that we have test cases to include in the run
# Empty runs are not allowed unless include_all is True
if not include_all and (not add_run_data.get("case_ids") or len(add_run_data["case_ids"]) == 0):
error_msg = (
"Cannot create test run: No test cases were matched.\n"
" - For parse_junit: Ensure tests have automation_id/test ids that matches existing cases in TestRail\n"
" - For parse_cucumber: Ensure features have names or @C test id tag matching the existing BDD cases"
)
return None, error_msg

if not plan_id:
response = self.client.send_post(f"add_run/{project_id}", add_run_data)
if response.error_message:
return None, response.error_message
run_id = response.response_text.get("id")
else:
if config_ids:
Expand All @@ -102,6 +115,8 @@ def add_run(
else:
entry_data = add_run_data
response = self.client.send_post(f"add_plan_entry/{plan_id}", entry_data)
if response.error_message:
return None, response.error_message
run_id = response.response_text["runs"][0]["id"]
return run_id, response.error_message

Expand Down