Skip to main content

How to send test results to Vansah from Java

Use the Vansah Java binding to automatically send test runs, step logs, results and screenshots from your Java automation (Maven, Playwright or any Java based automation framework) directly to Vansah Test Management for Jira.

Overview

The Vansah Java binding is a single class, VansahNode.java, that you add to your test project and call from your existing tests. It works with Selenium, Playwright (Java), JUnit, TestNG, Cucumber and other Maven-based frameworks, and connects to the Vansah REST API (v2).

Before you begin

Step-by-step

Step 1: Add the Maven dependencies

Add the two libraries the binding requires to your pom.xml.

Step 2: Add the VansahNode client to your project

  1. Copy the file src/main/java/com/vansah/VansahNode.java.

  2. Paste it into your test project.

Step 3: Configure the token, URL and Space Key

Create a VansahNode instance and set your token, API URL, and Space Key. The Space Key is your Jira project key and is required for API v2.

Where to find these: generate your token in Create a Vansah API Token, and copy your API URL from Vansah API Connect URL.

Note: The Space Key is sent as the top-level "project" object on every request so the run lands in the correct Space. A missing or blank Space Key prints a warning.

Step 4: Create a test run

Choose the run type that matches how your test case is organised. Set the matching context (issue key, folder path, or test plan key) first, then create the run.

Against a Jira Work item

Against a Test Folder

Not sure of the folder path? See Getting the folder path of a test folder. The path must contain a "/" and must not start with "/".

Against an Advanced Test Plan (ATP)

Against a Standard Test Plan (STP)

Note: Test plan runs target iteration 1 by default. To record results against a different iteration, call app.setTestPlanIteration(n) - where n is 1 to 5 - before addTestRunFromAdvancedTestPlan or addTestRunFromStandardTestPlan. This applies to Test Plan runs only, not Jira-issue or folder runs.

Step 5: Log your test results

For step-by-step tests, log a result for each step. The result can be a String (NA, FAILED, PASSED, UNTESTED - case-insensitive; note NA, not N/A) or an int (0 = N/A, 1 = FAIL, 2 = PASS, 3 = Not tested).

Tip: For a single overall result with no steps, use a Quick Test instead: app.addQuickTestFromJiraIssue("TEST-C1", 2); // 2 = PASS

Step 6: Attach a screenshot (optional)

Pass a screenshot File to addTestLog or updateTestLog and the binding uploads it and links it to the log.

Step 7: Enable debug logging (optional)

If a run or log is not appearing as expected, turn on payload logging to see the exact JSON the binding sends to Vansah.

Step 8: Run your tests and view results in Vansah

  1. Run your automated tests as usual.

  2. Open the linked Jira issue, test folder, or test plan in Vansah.

  3. Confirm the new test run and its step logs (and any screenshots) appear.

Full example (Folder, ATP and STP)

Method reference

  • addTestRunFromJIRAIssue(String testCase)

    Creates a run linked to a Jira issue (set via setJIRA_ISSUE_KEY).

  • addTestRunFromTestFolder(String testCase)

    Creates a run under a Vansah test folder (set via setFOLDERPATH).

  • addTestRunFromAdvancedTestPlan(String assetType, String testCase)

    Creates a run under an ATP. assetType is "folder" or "issue".

  • addTestRunFromStandardTestPlan(String testCase)

    Creates a run under a Standard Test Plan.

  • addTestLog(result, comment, step [, screenshot])

    Logs one step result (+ optional screenshot). result: String NA/FAILED/PASSED/UNTESTED or int 0-3.

  • updateTestLog(result, comment [, screenshot])

    Updates the most recent log with a new result/comment/screenshot.

  • addQuickTestFromJiraIssue(String testCase, int result)

    Single overall result against a Jira issue (int 0-3).

  • addQuickTestFromTestFolders(String testCase, int result)

    Single overall result under a test folder (int 0-3).

  • removeTestRun()

    Deletes the most recently created test run.

  • removeTestLog()

    Deletes the most recently created test log.

Configuration (setter) methods

  • setVansahToken(String token) - Vansah Connect token used to authenticate requests.

  • setVansahURL(String url) - Vansah API base URL

  • setProjectKey(String projectKey) - Space Key (Jira project key). Required for API v2.

  • setFOLDERPATH(String folderPath) - Test folder path. Must contain "/" and must not start with "/".

  • setJIRA_ISSUE_KEY(String issueKey) - Jira issue key to attach runs/logs to.

  • setSPRINT_NAME(String sprint) - Optional. Associates runs with a sprint.

  • setRELEASE_NAME(String release) - Optional. Associates runs with a release/version.

  • setENVIRONMENT_NAME(String environment) - Optional. Tags runs with an environment (e.g. SYS, UAT).

  • setAdvancedTestPlanKey(String key) - Advanced Test Plan key (e.g. KAN-P17).

  • setStandardTestPlanKey(String key) - Standard Test Plan key (e.g. KAN-P18).

  • setTestPlanIteration(int iteration) - Optional. Targets a specific STP/ATP iteration (1-5). Defaults to 1 if not set.

  • setDebug(boolean debug) - Enables request-payload logging. Also enabled via VANSAH_DEBUG=true.

Good to know

  • API version: the binding uses Vansah API v2. Older Connect tokens must be regenerated; v1 rejects Connect tokens.

  • Result values: strings are NA, FAILED, PASSED, UNTESTED (case-insensitive); integers are 0 = N/A, 1 = FAIL, 2 = PASS, 3 = Not tested.

  • Debug: set VANSAH_DEBUG=true (or call setDebug(true)) to print the exact JSON payload sent to Vansah.

Related articles

Did this answer your question?