Now inviting automation leaders: publish your playbook as a skill, under your own name. Publish yours →
Automation Skills
All skills/Uipath rpa/Testing-guide
Reference · Uipath rpa

Testing-guide

Part of Uipath rpa. Install the skill and your agent reads this page when it needs the depth.

Testing Guide

Reference for XAML test automation features in UiPath RPA projects — XAML test case structure, data-driven testing, XAML test activities, execution templates, and mock testing.

For coded test case creation (Given-When-Then, assertions, Before/After hooks), see coded/operations-guide.md § Add a Test Case File.

Table of Contents


Test Manager Setup (CLI)

Linking a project to Test Manager (server connection + default project) can be done headlessly with uip rpa tm, without opening Studio — useful before authoring test cases that reference Test Manager test cases. Commands, ordering constraints (connect before set-default-project, server switches clearing the default project), and reloadHint handling: cli-reference.md § Test Manager. The CLI does not validate the project id against the server; obtain a real id from Test Manager (the runtime uip tm project list tool can list them).


XAML Test Case Structure (Given-When-Then)

XAML test cases use a Given-When-Then structure — three nested <Sequence> elements inside a parent Sequence. The agent generates these directly as XAML.

XAML Structure — Test Case Invoking a Workflow

The core pattern: a parent Sequence with three child Sequences named "... Given", "... When", "... Then". The When section invokes the workflow under test. Verification activities go in Then, except a check of a state that later steps change (a confirmation after a save in an end-to-end flow): it sits right after the step that produces that state, in When or in a workflow When invokes. A verification records its assertion in the test result from any depth.

<!-- Body inside <Activity> (after namespaces/references) -->
<Sequence DisplayName="TestMyWorkflow">
  <!-- GIVEN — set up preconditions -->
  <Sequence DisplayName="... Given">
    <!-- Assign variables, open apps, prepare test data -->
  </Sequence>

  <!-- WHEN — execute the workflow under test -->
  <Sequence DisplayName="... When">
    <ui:InvokeWorkflowFile
      DisplayName="MyWorkflow - Invoke Workflow File (MyWorkflow.xaml)"
      WorkflowFileName="MyWorkflow.xaml"
      UnSafe="False">
      <ui:InvokeWorkflowFile.Arguments>
        <scg:Dictionary x:TypeArguments="x:String, Argument" />
      </ui:InvokeWorkflowFile.Arguments>
    </ui:InvokeWorkflowFile>
  </Sequence>

  <!-- THEN — verify results -->
  <Sequence DisplayName="... Then">
    <!-- VerifyExpression, VerifyExpressionWithOperator, etc. -->
  </Sequence>
</Sequence>

Required xmlns for InvokeWorkflowFile:

xmlns:ui="http://schemas.uipath.com/workflow/activities"

Default Values for Test-Case Arguments

A test case authored with an <x:Property Name="in_X" Type="InArgument(x:String)" /> argument should generally bake in a default so uip rpa run --file-path <TestCase>.xaml is runnable without --input-arguments. Use the canonical root-attribute syntax — see xaml/xaml-editing-catalog.md § Setting Default Values for Arguments. The wrong forms (bare attribute, <x:Property.Value>, <InArgument> child of <x:Property>) all produce confusing member not supported errors — the doc explicitly lists them so you don't waste time trying. An argument bound to a Data Service entity takes no default (§ Data Service Entity).

XAML Structure — Execution Template Placeholder

The ui:Placeholder sits in the execution template, where the case runs (§ Execution Templates); a bound case is an ordinary Given-When-Then file:

<Sequence DisplayName="Run case">
  <ui:Placeholder
    Description="This placeholder activity will be replaced at build time and can only be used within an execution template." />
</Sequence>

Passing Arguments to Invoked Workflows

If the workflow has arguments, pass them as entries of InvokeWorkflowFile.Arguments:

<ui:InvokeWorkflowFile WorkflowFileName="CalculateDiscount.xaml" UnSafe="False">
  <ui:InvokeWorkflowFile.Arguments>
    <InArgument x:TypeArguments="x:Decimal" x:Key="in_Amount">
      <CSharpValue x:TypeArguments="x:Decimal">1500.00m</CSharpValue>
    </InArgument>
    <InArgument x:TypeArguments="x:Decimal" x:Key="in_DiscountRate">
      <CSharpValue x:TypeArguments="x:Decimal">0.10m</CSharpValue>
    </InArgument>
  </ui:InvokeWorkflowFile.Arguments>
</ui:InvokeWorkflowFile>

project.json Registration

Register every XAML test case in designOptions.fileInfoCollection — this is Common Rule 10 in SKILL.md and applies to both XAML and coded test cases. Test cases live only in fileInfoCollection, never in entryPoints — entryPoints is for executable workflow files in Process projects (e.g. Main.xaml), and test cases are not workflow entry points regardless of project type.

Copy-paste JSON snippet (including publishAsTestCase for coded test cases and dataVariationFilePath for data-driven): ../assets/json-template.md.

Required keys per entry:

Template keys: an execution template is registered as its own entry (templateType ExecutionTemplate), a new-test-case template with templateType TestCase, and a case is bound to its execution template with executionTemplatePath and executionTemplateType on its entry. Shapes: ../assets/json-template.md; behaviour: § Execution Templates.

editingStatus lifecycle: Set to "InProgress" when creating a new test case. Update to "Publishable" only when the user explicitly asks to mark the test case as ready.

What NOT to Do


Data-Driven Testing

Data-driven testing executes the same test case multiple times with different input data sets. Each data row represents a separate test scenario.

Data Sources Overview

Source Where Data Lives Best For Agent Support
Variations files .variations/ folder in project File-based test data committed with the project CLI, Studio Desktop only: test-data add-variation. Headless: files (§ Adding Test Data via CLI)
Test Data Queues UiPath Orchestrator Large-scale distributed testing, parallel execution. To be deprecated at a later date CLI, Studio Desktop only: test-data add-queue
Data Service Data Fabric entity Centralized, shared test data, filtered per test case; records change without a republish Files: § Data Service Entity

For coded data-driven tests using default parameters, see coded/operations-guide.md § Add a Test Case File.

Variations Files (Coded & XAML)

Store test data in the .variations/ folder at the project root. Each JSON file maps to a test case and contains rows of input data.

MyProject/
├── .variations/
│   └── TestProcessInvoice.json
├── TestProcessInvoice.cs
└── project.json

The .variations/ directory is available in all project types (Process, Tests, Library). Data files must be in JSON format.

Adding Test Data via CLI

Two commands attach file and queue sources to a test case. Both register the data source in project metadata, extract arguments from the source schema, and add them to the test case (via Studio's workflow management API for XAML, via Roslyn for coded test cases). A Data Service source is written as files (§ Data Service Entity).

Studio Desktop only. Both commands need a running Studio Desktop with rpa-tool interop; headless Studio does not serve them. Without one (cli-reference.md § Headless Studio (Helm) vs Studio Desktop), write the variations file and the case's dataVariationFilePath per json-template.md § Data-driven test case and declare one test case argument per field. A Test Data Queue has no headless route: tell the user it needs Studio Desktop.

test-data add-variation — File-based (JSON)
uip rpa test-data add-variation --test-case-path "<TEST_CASE_FILE>" --data-variation-path "<DATA_FILE>" --project-dir "<PROJECT_DIR>" --output json
Parameter Required Description
--test-case-path Yes Relative path to the test case file (.xaml or .cs)
--data-variation-path Yes Relative path to the JSON data file in .variations/

Parses fields from the JSON file and creates one argument per field with matching type and a default value from the first entry.

Example:

uip rpa test-data add-variation --test-case-path "TestProcessInvoice.cs" --data-variation-path ".variations/InvoiceData.json" --project-dir "C:\MyProject" --output json
test-data add-queue — Orchestrator Test Data Queue

Prerequisite: Use the uipath-platform skill to discover queue details (name, ID, folder) before calling this command.

uip rpa test-data add-queue --test-case-path "<TEST_CASE_FILE>" --queue-name "<QUEUE_NAME>" --folder-path "<FOLDER>" --queue-id <ID> --project-dir "<PROJECT_DIR>" --output json
Parameter Required Description
--test-case-path Yes Relative path to the test case (.xaml or .cs)
--queue-name Yes Name of the Test Data Queue in Orchestrator
--folder-path Yes Orchestrator folder path
--queue-id Yes Orchestrator ID of the queue

Creates an IDictionary<string, object> argument named after the queue (camelCase).

Example:

uip rpa test-data add-queue --test-case-path "TestLoanApproval.cs" --queue-name "loan_applications" --folder-path "Shared" --queue-id 123 --project-dir "C:\MyProject" --output json

Critical: Do NOT rename the auto-generated test data queue argument. If you change its name, data retrieval silently fails.

Data Service Entity

Every record matching the test case's filter is one variation: Test Manager runs the case once per record. Records are queried when the run starts, so records added or edited later need no republish.

Prerequisites:

  1. Discover / verify entities — run uip rpa data-fabric-entities list --project-dir "<PROJECT_DIR>" --output json to see what is installed and what is available in the connected tenant. (Alternatively, the uipath-platform skill can discover entities directly in Orchestrator.)
  2. Install the target entity into the project if not already installed — uip rpa data-fabric-entities install --add "<ENTITY_NAME>" --project-dir "<PROJECT_DIR>" --output json. The test case uses the entity's generated type. See cli-reference.md § Data Fabric Entities.

Write the binding as the four files below. Do not use uip rpa test-data add-entity: it runs only in Studio Desktop, takes no filter, leaves the argument and the project.json entry unsaved in the open designer, and writes the entity's first record (user names and emails included) as the argument's default.

<NAMESPACE> = project.json → entitiesStores[0].namespace. <ARG> = entity name in camelCase; keep it exactly, the data binds by this name.

  1. .variations/<ENTITY>_<NAME>.json — <NAME> names the filter (short: the generated setup workflow is named after the file):
    {"EntityName":"<ENTITY>","TypeName":"<NAMESPACE>.<ENTITY>","Filters":"<BASE64_QUERY>","TestCaseId":"<UUID_V4>","Name":"<NAME>"}
    
    TestCaseId is a fresh GUID, not the case's. At pack, Studio generates from this file a setup workflow with that id (.generated/.setup/Fetch <ENTITY>_<NAME> Test Data.xaml); it queries the entity and passes each record to the case.
  2. .variations/config.json — append {"filePath": ".variations\\<ENTITY>_<NAME>.json", "dataVariationType": "Entity"} to dataVariationFileInfo (create {"dataVariationFileInfo": [...]} when absent).
  3. project.json — the case's fileInfoCollection entry gets "dataVariationFilePath": ".variations\\<ENTITY>_<NAME>.json", after testCaseId (Studio's order).
  4. Test case argument, typed as the entity, no default:
    • XAML: <x:Property Name="<ARG>" Type="InArgument(local:<ENTITY>)" /> with xmlns:local="clr-namespace:<NAMESPACE>;assembly=DataService.<NAMESPACE>", namespace import UiPath.DataService.Definition and <NAMESPACE>, assembly references UiPath.DataService.Definition and DataService.<NAMESPACE>.
    • Coded: [TestCase] public void Execute(<NAMESPACE>.<ENTITY> <ARG>).
    • UiPath.DataService.Activities is not needed for the data source alone.

Filters = Base64 of the UTF-8 JSON Studio's Query Builder saves. Written in that form, the builder opens it and saves it unchanged:

{"SelectedFields":null,"Start":0,"Limit":1000,"SortOptions":null,"Expansions":null,"FilterGroup":{"LogicalOperator":0,"QueryFilters":[{"FieldName":"<FIELD>","Operator":"=","Value":"<VALUE>"}],"FilterGroups":[]}}

Run-time behaviour:

One Entity for a Project's Test Data

A test project keeps all its Data Service test data in one entity, one record per data row, with three fields:

Field Type Holds
Data set text name of the data set the row belongs to, unique within the project
Row order number, no decimals row's position in its data set, from 1
Row long text (MULTILINE_TEXT) the row as one JSON object of text values, every field of its data set present, an empty value as ""

Name the entity after the project and its fields under Data Fabric's naming rules (uipath-platform). Do not type the row field MULTILINE_MAX: list and query reads return only a preview of it (uipath-platform). One entity is one definition, one install and one load, and a data set that gains a field changes no entity; Data Fabric cannot filter on a value inside the row, so criteria on row values run in code after the parse.

Data-Driven Testing Best Practices

  1. Separate test data from test logic — keep data in external sources, not hardcoded in test cases
  2. Include both positive and negative scenarios — test expected failures too (invalid inputs, boundary values)
  3. Name data fields descriptively — use field names like ExpectedResult, Scenario for traceability
  4. Keep data sets small and focused — each data set should test one concern; avoid combinatorial explosion
  5. Use JSON format for .variations/ data files

XAML Test Activities

The UiPath.Testing.Activities package provides XAML-specific test activities beyond what the coded testing service offers.

Verification Activities

Activity Purpose Key Properties
VerifyExpression Assert a boolean expression is true Expression, OutputMessageFormat
VerifyExpressionWithOperator Assert two values with a comparison operator FirstExpression, SecondExpression, Operator
VerifyRange Assert a value is within (or not within) inclusive bounds Expression, LowerLimit, UpperLimit, VerificationType
VerifyControlAttribute Assert an output of the one UI activity it wraps ActivityToTest, OutputArgument, Operator, Expression

Choose by the check, so the assertion's default message shows the values compared:

The check Activity
A UI element's value or state against an expected value VerifyControlAttribute around the activity that reads it: Get Text, Get Attribute, or Check App State's Exists for "is shown" — never a read into a variable and a separate assertion
Two values: equal, not equal, contains, a regex, greater or less VerifyExpressionWithOperator
A value inside or outside two bounds VerifyRange
Anything else — starts with, does not contain, case-insensitive, several conditions VerifyExpression, with an OutputMessageFormat showing the values

VerifyExpressionWithOperator

Compares two expressions using a comparison operator from the Comparison enum. Both FirstExpression and SecondExpression are InArgument<Object> — they accept any type; relational comparisons rely on the runtime types implementing IComparable.

Properties:

Authoritative reference: {projectRoot}/.local/docs/packages/UiPath.Testing.Activities/activities/VerifyExpressionWithOperator.md. Read the activity doc whenever this skill summary disagrees with it — the activity doc wins.

No "starts with" / "ends with" / "does not contain" operators. For substring containment, use Contains (asserts FirstExpression contains SecondExpression). For prefix/suffix or "does not contain" assertions, use VerifyExpression with a boolean C#/VB expression (e.g. actualValue.StartsWith("foo"), Not actualValue.Contains("bar")). For regex, use RegexMatch and pass the pattern in SecondExpression.

Text operands are compared as patterns, with case. Equality and Inequality match SecondExpression as a wildcard pattern against the whole text: * any characters, ? one character, # one digit, \ escaping each. An expected value holding *, ? or # escapes them (PO \#123), or PO #123 also matches PO 1123 and not itself. Equality, Inequality and Contains are case-sensitive; RegexMatch is too unless the pattern starts with (?i). A case-insensitive check is RegexMatch with (?i) and the escaped value, or a VerifyExpression. VerifyControlAttribute compares the same way.

VerifyControlAttribute

Wraps exactly one UI Automation activity and asserts one of its output properties against an expected value: the read and the check are one activity.

Requires UI automation targets. The wrapped activity inspects live UI elements at runtime. The UIA package guide ({PROJECT_DIR}/.local/docs/packages/UiPath.UIAutomation.Activities/ui-automation-guide.md) MUST be read IN FULL first (SKILL.md Rule 7). The agent must configure the wrapped activity's target using uia-configure-target. The test case must run against a live application instance.

Properties:

Element syntax, validation constraints and example: the activity's own doc ({projectRoot}/.local/docs/packages/UiPath.Testing.Activities/activities/VerifyControlAttribute.md), read before authoring.

Constraints:

Assertion Results

Each verification activity records one assertion in the test case result. Shared properties and their per-activity defaults: package overview § Shared Assertion Properties.

Given-When-Then in XAML

The Given-When-Then structure is three nested <Sequence> elements — not separate activity types. See § XAML Test Case Structure above for the full XAML patterns and agent workflow.

Place verification activities inside the "... Then" Sequence, mid-flow checks excepted (§ XAML Structure — Test Case Invoking a Workflow).

XAML Test Activity Gotchas


Execution Templates

Execution templates wrap test cases at runtime with predefined execution conditions. They let you reuse the same test case logic across different environments, configurations, or application states without duplicating test code. Setup, teardown, a timeout and failure capture written in the template apply to every case it wraps.

When to Use Execution Templates

How Execution Templates Work

  1. Create an execution template: right-click the Templates folder → Add → Execution Template. On disk it is a workflow in .templates\ holding one ui:Placeholder (§ Execution Template Placeholder), registered as an ExecutionTemplate entry; each case it wraps names it with executionTemplatePath and executionTemplateType "Local" (§ project.json Registration). A case whose entry names no template runs bare.
  2. Define variables and arguments in the template that match names in the test case
  3. At runtime, Studio merges the test case and template into a temporary file:
    • Arguments with matching names are linked — template values override test case defaults
    • Variables with matching names are linked — template values take precedence
    • Non-overlapping arguments/variables from both files are included as-is
  4. uip rpa pack writes .generated\<case path>.xaml for each bound case: the template with its Placeholder replaced by an Invoke Workflow File of the case. These generated files are the package's entry points (each uniqueId is the case's testCaseId), so Orchestrator and Test Manager runs execute each bound case inside its template. In the generated file only arguments reach the case, by name; a template variable does not — state the template sets up for the cases goes through global variables (xaml/xaml-editing-catalog.md § Global Variables).

Test Automation Framework

The Official Test Automation Framework template (uip rpa templates search --query "Test Automation Framework") is the starting point for a test project, as the REFramework is for a transactional process; it ships Windows and cross-platform variants in both expression languages. Its execution template runs every bound case inside one root TryCatch:

  1. Try — a coded initializer loads the project's configuration files into one Config dictionary (a global variable), the run's test name is added to it, then a Timeout Scope bounded by the test-timeout setting runs the setup hook and the case.
  2. Catch — any exception, from the configuration load, the setup hook or the case, is recorded as a failed Verify Expression with its failure screenshot, the finalize step runs with the exception, and the exception is rethrown, so the case fails with evidence.
  3. Finally — the finalize step runs after a pass. A rethrow from a workflow's root TryCatch skips its Finally (error-handling-guide.md rule 5), which is why the Catch calls the finalize step itself.

The finalize step runs the teardown hook within its own timeout and logs a teardown failure without failing the case. Cleanup such as closing the application goes in the teardown hook, preconditions in the setup hook; a case keeps no failure wrapper and no configuration load of its own.

Configuration. Settings and constants are entries with a text value; assets are entries naming an Orchestrator asset or credential asset, read when the case starts. Entry names are unique across the files, and each entry is read by name from Config (xaml/xaml-editing-catalog.md § Global Variables). The file formats, the reserved and required entries, and the example_ entries to remove or replace before a run are in the scaffolded README.md; read it and the scaffolded files before changing them.

After init, check two things and fix what is missing:

Execution Template Structure

MyProject/
├── .templates/
│   ├── StagingEnvironment.xaml       ← sets environment-specific variables
│   └── ProductionEnvironment.xaml    ← different config for prod
├── TestCases/
│   └── TestInvoiceProcessing.xaml    ← generic test, environment-agnostic
└── project.json

Key Rules

  1. Name matching is exact — argument/variable names in the template must match the test case exactly (case-sensitive) for linking to work
  2. Templates do not execute independently — they only run when associated with a test case
  3. One template per execution — a test case runs with one execution template at a time; select it in Test Explorer before running
  4. Template arguments override test case defaults — use this to inject environment-specific values (URLs, credentials, timeouts)

What NOT to Do with Execution Templates


Mock Testing (XAML Only) — WIP

This section is a work in progress. Full agent support for mock testing requires a CLI command to create mock copies of workflows (e.g., uip rpa create-mock --file-path <WORKFLOW> --project-dir <DIR>). Until that command exists, the agent can generate the test case XAML but cannot reliably create mock files programmatically.

Mock testing replaces selected activities or entire invoked workflows with lightweight stand-ins during a test run, isolating the code under test from side effects (database writes, API calls, UI interactions).

Coded test cases have no built-in mock framework. There is no coded equivalent. To isolate dependencies in coded tests, design workflows with injectable parameters or test individual workflows in isolation.

How Mocking Works

  1. The test case's When container invokes a mock copy instead of the original workflow
  2. The mock copy lives at Mocks/<workflow>_mock.xaml (mirrors source folder structure)
  3. Inside the mock, specific activities are replaced with stand-ins that return predefined values
  4. At runtime, mocked activities skip their real logic and return the configured test data

Test Case with Mock — XAML Structure

<!-- When container invokes the mock copy instead of the original -->
<Sequence DisplayName="... When">
  <ui:InvokeWorkflowFile
    DisplayName="Main_mock - Invoke Workflow File (Mocks\Main_mock.xaml)"
    WorkflowFileName="Mocks\Main_mock.xaml"
    UnSafe="False">
    <ui:InvokeWorkflowFile.Arguments>
      <scg:Dictionary x:TypeArguments="x:String, Argument" />
    </ui:InvokeWorkflowFile.Arguments>
  </ui:InvokeWorkflowFile>
</Sequence>

Mocks Folder Structure

MyProject/
├── Main.xaml                         ← original workflow
├── Mocks/
│   └── Main_mock.xaml                ← mock copy of Main.xaml
├── TestCase.xaml                     ← test case invoking Mocks\Main_mock.xaml
├── TestCaseNoMock.xaml               ← test case invoking Main.xaml directly
└── project.json

For workflows in subdirectories, the Mocks folder mirrors the source path:

MyProject/
├── Workflows/
│   └── ProcessInvoice.xaml
├── Mocks/
│   └── Workflows/
│       └── ProcessInvoice_mock.xaml

Mock File Behavior

What the Agent Cannot Do Yet

  1. Create mock files — there is no uip rpa create-mock CLI command. The mock file must be created via Studio's "Create Test Case" dialog with the "Mock workflow under test" checkbox, or manually copied (but Studio manages internal mock metadata that a raw file copy may miss).
  2. Surround with Mock — wrapping individual activities in mock containers is a Studio GUI action. The agent cannot replicate this in XAML without the internal mock activity schema.

Constraints

  1. Process projects only — mocking is NOT available in Test Automation (Tests) projects
  2. XAML only — no mock framework for coded test cases
  3. When container only — mock invocations go inside the "... When" Sequence
  4. No nested mocks — a mock container cannot be nested inside another mock container
  5. Package dependency — requires UiPath.Testing.Activities installed

Publish your skill

Copy this prompt into Claude Code, Codex or any agent. It walks you through your first skill in about 20 minutes, with you as the author.

Click to copy.