Use the Vansah C# binding to send results from your .NET test automation to Vansah. Add VansahNode.cs to your test project and call it from your existing tests to create Test Runs, record step results and attach screenshots.
You can report against Jira work items, Test Folders, Standard Test Plans or Advanced Test Plans. The binding records the outcomes your automation provides; it does not run the tests for you.
Before you begin
Install Vansah Test Management for Jira and create the Test Cases you want to report against.
Create a Vansah API token and find your site’s API Connect URL.
Have your Jira space key and the target work item, folder or plan details.
Use a .NET 6.0 or newer project. The binding’s current project targets .NET 6.0 and references Newtonsoft.Json 13.0.3.
Make sure your account can execute the tests. For a Test Plan, its iteration must exist and include the Test Case in the intended requirement.
1. Add the dependency and binding
From your test project directory, add the JSON dependency:
dotnet add package Newtonsoft.Json --version 13.0.3
Download VansahNode.cs from the official repository and add it to your test project.
Use
using Vansah;in the file that calls the binding. Use the current binding file when upgrading an older integration; it targets Vansah API v2.
2. Configure the connection
Provide the token, API Connect URL and Jira space key through your environment or pipeline settings. Keep the token in a secret store. This example uses VANSAH_TOKEN, VANSAH_URL and VANSAH_PROJECT_KEY:
using System;
using Vansah;
VansahNode app = new VansahNode();
app.SetVansahToken = Environment.GetEnvironmentVariable("VANSAH_TOKEN");
app.SetVansahURL = Environment.GetEnvironmentVariable("VANSAH_URL");
app.SpaceKey = Environment.GetEnvironmentVariable("VANSAH_PROJECT_KEY");
SpaceKey is the Jira space key, such as DEMO. SetVansahURL accepts the base API Connect URL shown in Vansah settings; the binding adds the API path.
Optional run properties can be set before creating the run. Keep these property names exactly as shown:
app.environment_Name = "UAT";
app.SprintName = "Sprint 1";
app.release_Name = "Release 1";
3. Choose where to create the Test Run
Choose one destination for each run. Replace the sample keys and paths with records from your site, then use the same instance to record the run’s step results.
Jira work item
app.JiraIssueKey = "DEMO-9";
app.AddTestRunFromJiraIssue("DEMO-C50");
Test Folder
app.TestFolderID = "regression/login/";
app.AddTestRunFromTestFolder("DEMO-C50");
Despite its name, TestFolderID takes a folder path. The path must contain / and must not start with /. See Getting the folder path of a Test Folder.
Standard Test Plan
app.setStandardTestPlanKey("DEMO-P2");
app.setTestPlanIteration(2);
app.AddTestRunFromStandardTestPlan("DEMO-C50");
Advanced Test Plan
Set the plan and the requirement within it. For a Jira work item requirement:
app.setAdvancedTestPlanKey("DEMO-P1");
app.setTestPlanIteration(2);
app.JiraIssueKey = "DEMO-9";
app.AddTestRunFromAdvancedTestPlan("issue", "DEMO-C50");For a folder requirement, set its path and use "folder":
app.TestFolderID = "regression/login/";
app.AddTestRunFromAdvancedTestPlan("folder", "DEMO-C50");
Iteration behavior: Test Plan runs default to iteration 1. This C# binding accepts integers 1 through 5 in setTestPlanIteration; call it before creating the run. This range is a binding limitation, not the total number of iterations Vansah can hold. The setting does not affect work item or folder runs.
4. Record the result for each step
After your automation performs a step, call AddTestLog with its actual result, a comment and the matching Test Case step number. Step numbers start at 1.
app.AddTestLog("passed", "The sign-in form opened.", 1);
app.AddTestLog("failed", "The confirmation message did not appear.", 2);The run starts as Untested. As you submit results, the binding updates the matching step logs. Only report results observed by your test automation.
Result name | Numeric value |
| 0 — N/A |
| 1 — Failed |
| 2 — Passed |
| 3 — Untested |
Names are case-insensitive. Use NA for N/A. Unknown strings fall back to N/A in the current binding, so avoid arbitrary result names.
5. Attach a screenshot or update the latest log
Pass a screenshot file path as the fourth argument to AddTestLog:
app.AddTestLog(
"failed",
"The confirmation message did not appear.",
2,
"screenshots/confirmation.png"
);
The file must exist on the test runner. To revise the most recently recorded log, use UpdateTestLog:
app.UpdateTestLog(
"failed",
"Rechecked: the confirmation message is still missing.",
"screenshots/recheck.png"
);
Record one overall result with a Quick Test
For a Jira work item result with no step-by-step reporting, use the following after configuring the connection:
app.JiraIssueKey = "DEMO-9";
app.AddQuickTestFromJiraIssue("DEMO-C50", "passed");
For a Test Folder, set TestFolderID and call AddQuickTestFromTestFolders. A Quick Test creates the run and records its overall result in one call.
Useful methods
Method | Purpose |
| Record a step result. Add a screenshot path as the fourth argument when needed. |
| Revise the latest log. An optional third argument supplies a screenshot path. |
| Delete the current run stored by the instance. |
| Delete the current log. When its step is known, the binding restores an Untested entry. |
| Print outgoing request details for troubleshooting. |
Troubleshooting
Problem | What to check |
Missing class or dependency | Confirm that VansahNode.cs is included in the project, Newtonsoft.Json is installed and the calling file imports the Vansah namespace. |
Run or log does not appear | Check the console response, token, API URL, SpaceKey and permissions. Create the run successfully before recording logs. |
Plan or iteration error | Confirm that the case is in the selected plan requirement and the iteration exists. This binding accepts iteration numbers 1–5. |
Screenshot is missing | Check the path on the machine running the test. A workstation file may not exist on the pipeline runner. |
Incorrect result | Check the step number and supported result string or numeric value. |
Use app.setDebug(true); when you need request details. Review logs for sensitive test data before sharing them.
Check the saved results
Open the destination work item, Test Folder or Test Plan in Vansah. For a plan, select the relevant iteration. Review the Test Run, step results, comments and attachments.
More help
See the official C# binding repository for the latest class and examples. For report uploads from a pipeline, see Sending Automated Test Results to Vansah from CI/CD.
