Use the Vansah Java binding to send automated test results from your Java code to Vansah. It provides methods to create Test Runs, record step results, and attach screenshots. Call these methods from your tests or framework hooks, including JUnit, TestNG, or Cucumber workflows; the binding does not automatically discover and report your tests.
Before you begin
Use Java JDK 8 or later and a Maven test project.
Install Vansah on your Jira site. The account behind your API token needs access to the Jira space and permission to execute Test Cases.
Generate a Vansah API token and find your workspace’s Vansah API Connect URL.
For the example below, choose an existing Test Folder and a Test Case linked to it with at least one script step. Replace all DEMO values with values from your own Jira space.
1. Add the Java client to your project
Open the official Vansah Java binding repository and use the prod branch.
Copy
src/main/java/com/vansah/VansahNode.javainto your Maven test project assrc/test/java/com/vansah/VansahNode.java. Keep itspackage com.vansah;declaration aligned with that folder.Add the dependencies below to
pom.xml. If it already has a<dependencies>section, merge the two dependency entries into it.Reload or import the Maven project in your IDE so the dependencies are available.
These dependency versions match the binding’s sample project:
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
2. Configure your connection
Set these environment variables in your IDE run configuration or CI secret settings:
Variable | Value |
| Your workspace’s Vansah API Connect URL, without a trailing slash or |
| Your Vansah API token. Pass the token value only; do not add |
The example reads these variables with System.getenv. setProjectKey("DEMO") sets the Jira space key; the API field remains named project.key.
3. Create a run and record a step result
Save this complete example as src/test/java/com/vansah/VansahJavaExample.java. Replace DEMO, DEMO-C46, and regression/checkout/ with your Jira space key, Test Case key, and exact Test Folder path. The folder path has no Jira space key prefix and must not start with /.
package com.vansah;
public final class VansahJavaExample {
public static void main(String[] args) throws Exception {
VansahNode.setVansahURL(required("VANSAH_URL"));
VansahNode.setVansahToken(required("VANSAH_TOKEN"));
VansahNode.setProjectKey("DEMO");
VansahNode results = new VansahNode();
results.setFOLDERPATH("regression/checkout/");
results.addTestRunFromTestFolder("DEMO-C46");
results.addTestLog("passed", "Checkout confirmation appeared.", 1);
}
private static String required(String name) {
String value = System.getenv(name);
if (value == null || value.trim().isEmpty()) {
throw new IllegalStateException("Set " + name + " before running.");
}
return value.trim();
}
}
Run the class’s main method from your IDE with the Maven test classpath and the environment variables configured. Running it creates a Test Run and records the sample result. In your automation, call addTestLog after checking the actual outcome and send "passed" or "failed" as appropriate.
Use the same VansahNode instance to create the run and record its step results. Step numbers start at 1 for a script with steps. The accepted result names are "passed", "failed", "untested", and "NA", case-insensitive. Use NA rather than N/A.
4. Check the result in Vansah
Review the console output for the Vansah success or error message. Confirm that run creation succeeded before relying on the step result.
Open the same Jira space and Test Case in Vansah.
Check its Test Runs for the new run and confirm the step result and actual-result comment.
A passing Java test does not by itself confirm that a result was saved in Vansah. The binding catches some errors and prints them, so review its output and the saved Test Run.
Use the binding in your automation
For work item and Test Plan examples, screenshot attachments, and additional methods, see Sending Test Results to Vansah from Java. For other languages, see Vansah API Bindings.
Keep your existing framework’s assertions and pass/fail handling. Add Vansah reporting at the appropriate test step or completion hook. Configure the API URL, token, and Jira space before reporting; these connection settings are shared across Java binding instances in the same process.
Troubleshooting
Problem | What to check |
Java cannot find VansahNode | Check the package declaration and file location, then reload the Maven project. |
Dependencies cannot be resolved | Check the dependency entries, Maven access, and the IDE’s Maven import. |
Authentication or access is denied | Check the API URL, token, Jira space access, and permission to execute Test Cases. |
The folder or Test Case cannot be found | Use the correct Jira space key, readable Test Case key, and exact folder path from that space. |
The result is unexpected or missing | Use a supported result name and the correct script step number. Review the console output and check that the run was created successfully. |
