Skip to main content
Version: 8.8 (unreleased)

Test scenario files

Camunda 8 only

Test scenario files let you define shareable, low-code tests for your BPMN processes.

They are stored in JSON format and can be created, edited, and managed directly in Web Modeler. You can also download these files or synchronize them with your Git repository using Git Sync.

Create a test scenario file

You can create a test scenario file by saving a scenario in Play, or by manually creating a test scenario file in Web Modeler.

Manual editing

Test case structure

Test scenario files are organized as follows:

{
"processId": "order-fulfillment-process",
"testCases": [
{
"name": "Happy path order processing",
"instructions": [
// Array of instruction objects
],
"metadata": {
// Optional - for use in Play only
"processInstanceId": 12345,
"coveredFlowNodes": [
{ "flowNodeId": "startEvent", "elementType": "START_EVENT" },
{ "flowNodeId": "processOrder", "elementType": "SERVICE_TASK" }
],
"coveredSequenceFlows": ["flow1", "flow2"]
}
},
{
"name": "Error handling scenario",
"instructions": [
// Array of instruction objects for error case
]
}
]
}

Top-level fields

FieldRequiredDescription
processIdYesThe ID of the BPMN process definition the test cases run against.
testCasesYesAn array of test case objects.

Test case fields

FieldRequiredDescription
nameNoA descriptive name for the test case scenario.
instructionsYesAn array of instruction objects that define the test steps.
metadataNoUsed by Play to show coverage and process instance details. Camunda does not recommend editing this field.

To display the file's scenarios in Play, you must first link the file to a process.

Add a processId field with the process ID of the BPMN process you want to test:

{
"processId": "Process_1"
}
note

Play runs only the first executable process within the BPMN diagram. Make sure the process ID you link is the first executable process.

To unlink the file from a process, remove the processId field or set it to null.

Instructions

Common patterns

  • Variables: Provide variables as JSON strings.
  • Element IDs: Reference specific BPMN elements in your process definition.
  • Process definition IDs: Identify which process definition to interact with.

Update variables

Updates process variables during test execution.

Fields

FieldRequiredDescription
typeYesMust be "update-variables".
variablesYesA JSON string containing the variables to update.

Example:

{
"type": "update-variables",
"variables": "{\"customerId\": \"12345\", \"amount\": 100.50}"
}

Create process instance

Creates a new process instance from a process definition.

Fields

FieldRequiredDescription
typeYesMust be "create-process-instance".
processDefinitionIdYesThe ID of the process definition to instantiate.
variablesNoA JSON string containing initial process variables.

Example:

{
"type": "create-process-instance",
"processDefinitionId": "order-process",
"variables": "{\"orderId\": \"ORD-001\", \"priority\": \"high\"}"
}

Create process instance by message

Creates a new process instance by sending a message to a message start event.

Fields

FieldRequiredDescription
typeYesMust be "create-process-instance-by-message".
processDefinitionIdYesThe ID of the process definition to instantiate.
messageNameYesThe name of the message that triggers the process start.
variablesNoA JSON string containing initial process variables.

Example:

{
"type": "create-process-instance-by-message",
"processDefinitionId": "message-triggered-process",
"messageName": "OrderReceived",
"variables": "{\"orderData\": \"sample data\"}"
}

Create process instance by signal

Creates a new process instance by broadcasting a signal to a signal start event.

Fields

FieldRequiredDescription
typeYesMust be "create-process-instance-by-signal".
processDefinitionIdYesThe ID of the process definition to instantiate.
signalNameYesThe name of the signal that triggers the process start.
variablesNoA JSON string containing initial process variables.

Example:

{
"type": "create-process-instance-by-signal",
"processDefinitionId": "signal-triggered-process",
"signalName": "MarketOpened",
"variables": "{\"marketData\": \"current rates\"}"
}

Complete job

Completes a service task job during process execution.

Fields

FieldRequiredDescription
typeYesMust be "complete-job".
jobTypeYesThe task’s job type (also called the task definition type).
elementIdYesThe ID of the BPMN element (service task) to complete.
variablesNoA JSON string containing variables to set when completing the job.

Example:

{
"type": "complete-job",
"jobType": "payment-service",
"elementId": "processPayment",
"variables": "{\"paymentResult\": \"success\", \"transactionId\": \"TXN-123\"}"
}

Broadcast signal

Broadcasts a signal that can be caught by signal intermediate catch events or signal boundary events.

Fields

FieldRequiredDescription
typeYesMust be "broadcast-signal".
elementIdYesThe ID of the BPMN element that will catch the signal.
signalNameYesThe name of the signal to broadcast.
variablesNoA JSON string containing variables to pass with the signal.

Example:

{
"type": "broadcast-signal",
"elementId": "waitForApproval",
"signalName": "ApprovalReceived",
"variables": "{\"approved\": true, \"approver\": \"manager@company.com\"}"
}

Complete user task

Completes a user task with optional form data or variables.

Fields

FieldRequiredDescription
typeYesMust be "complete-user-task".
elementIdYesThe ID of the BPMN user task element to complete.
variablesNoA JSON string containing form data or variables to submit.

Example:

{
"type": "complete-user-task",
"elementId": "reviewOrder",
"variables": "{\"reviewComment\": \"Order looks good\", \"approved\": true}"
}

Publish message

Publishes a message that can be caught by message intermediate catch events or message boundary events.

Fields

FieldRequiredDescription
typeYesMust be "publish-message".
elementIdYesThe ID of the BPMN element that will catch the message.
messageNameYesThe name of the message to publish.
correlationKeyYesThe correlation key used to match the message to the correct process instance.
variablesNoA JSON string containing variables to pass with the message.
timeToLiveNoHow long the message should remain available for correlation, in milliseconds as a string (e.g., "300000" for five minutes).
messageIdNoUnique identifier for the message to prevent duplicate processing.

Example:

{
"type": "publish-message",
"elementId": "waitForPayment",
"messageName": "PaymentConfirmed",
"correlationKey": "order-12345",
"variables": "{\"paymentAmount\": 99.99, \"paymentMethod\": \"credit_card\"}",
"timeToLive": "300000",
"messageId": "payment-msg-001"
}

Throw job error

Simulates a job failure by throwing an error during service task execution.

Fields

FieldRequiredDescription
typeYesMust be "throw-job-error".
elementIdYesThe ID of the BPMN service task element where the error occurs.
errorCodeYesThe error code that will be matched with an error catch event.
jobTypeNoThe type of job that failed (useful when multiple job types exist for the same element).
errorMessageNoHuman-readable description of the error.

Example:

{
"type": "throw-job-error",
"elementId": "processPayment",
"errorCode": "PAYMENT_FAILED",
"jobType": "payment-service",
"errorMessage": "Insufficient funds in customer account"
}

Resolve incident

Resolves an incident that was created due to a job failure or another process issue.

Fields

FieldRequiredDescription
typeYesMust be "resolve-incident".
elementIdYesThe ID of the BPMN element where the incident occurred.
hasJobYesBoolean indicating whether the incident is related to a job that should be retried after resolution.

Example:

{
"type": "resolve-incident",
"elementId": "processPayment",
"hasJob": true
}

Usage tips

  • Always use meaningful elementId values that match your BPMN diagram.
  • Give test cases descriptive names to clearly indicate the scenario being tested.
  • Include error scenarios along with happy path tests.
  • Use optional variables fields to test different data conditions.
  • Ensure correlation keys uniquely identify process instances.
  • Specify timeToLive values in milliseconds as a string (e.g., "60000" for one minute, "300000" for five minutes).