Skip to main content

Listener API Clients

Introduction

Orangebeard provides listener api clients for Java, Javascript/Typescript, .Net and Python to easily connect test tools and frameworks to Orangebeard's listener API. Our clients are open source so you can adapt them to your own specific needs.

This document describes the clients built for Listener API V3.

Source code

JavaScript Client
Java Client
.Net Client
Python Client

The clients allow to easily connect your javascript based test framework to the Orangebeard listener API. We provide integrations for multiple test tools, but if you need to roll your own, the clients are a convenient base to start from.

Installation

Package managers

See the client repositories readme files for detailed instructions. The clients can be installed from public package management repositories.

Maven:

<dependency>
<groupId>io.orangebeard</groupId>
<artifactId>java-client</artifactId>
<version>3.0.0</version>
</dependency>

Gradle:

implementation 'io.orangebeard:java-client:3.0.0'

Or build your client from source.

Configuration

Usually, the client is used from a listener that connects the client to a test tool. Listeners can provide their own OrangebeardParameters object.
If no configuration object is provided, the client will try to auto-configure in the following ways:

Auto-config

The automatic configuration looks for a config file named orangebeard.json in the current working directory or higher in the hierarchy (it will scan all the way up to /). The json file is expected to contain an OrangebeardParameters object:

{
endpoint: "https://my.orangebeard.app",
token: "xxxxxxxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx",
project: "my-project",
testset: "Test set name",
description: "Test run description",
attributes: [
{
key: "Key 1",
value: "Some value"
},
{
value: "Tag value"
}
],
ref_url: "https://my-build-reference.url"
}
tip

The Java Client supports automatic configuration through system properties. These can be set from a orangebeard.properties in the resource directory. In that case the hierarchy is that automatic configuration will read (and overwrite if applicable) properties in the following order:

  1. Orangebeard.properties
  2. System properties
  3. Orangebeard.json
  4. Environment variables

Environment variables

The auto config will scan for environment variables:

ORANGEBEARD_ENDPOINT=https://my.orangebeard.app
ORANGEBEARD_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
ORANGEBEARD_PROJECT=my-project
ORANGEBEARD_TESTSET=test set name
ORANGEBEARD_DESCRIPTION=Test run description
ORANGEBEARD_ATTRIBUTES=key:value; value;
ORANGEBEARD_REF_URL=https://my-build-reference.url
tip

If automatic client configuration is used and a value is present in both orangebeard.json and in the environment settings, the environment setting will take precedence.

The environment variables can be both written as orangebeard_varname and orangebeard.varname.

Usage

The client can be used by constructing an instance in any of the supported languages:

//Using the client's auto config:
OrangebeardAsyncV3Client client = new OrangebeardAsyncV3Client();

//Or pass a configuration object
OrangebeardAsyncV3Client client = new OrangebeardAsyncV3Client(
new OrangebeardProperties (
orangebeardEndpoint,
accessToken,
projectName,
testSetName,
description, //OPTIONAL test run description
attributes, //OPTIONAL test run attributes - Set<Attribute>
logLevel, //OPTIONAL LogLevel (and up) to report
false //OPTIONAL if enable: send test logs at the end of a test
);
);

Client API

The client exposes all public methods required to report a test run to Orangebeard.

Starting a test run

Starts a test run in Orangebeard and returns the UUID (Guid) of the test run that was started.

StartV3TestRun startTestRun = new StartV3TestRun(
testSetName,
testRunDescription,
testRunAttributes
);

UUID testRunUUID = orangebeardClient.startTestRun(startTestRun);

Starting an announced test run

Marks a test run that was previously announced in Orangebeard as started (Sets status to IN_PROGRESS).

orangebeardClient.startAnnouncedTestRun(testRunUUID);

Finishing a test run

Waits for all reporting calls to complete and marks the test run finished in Orangebeard.

orangebeardClient.finishTestRun(testRunUUID, new FinishV3TestRun());

Starting a suite

Starts (a structure of) suite(S) in the test run and returns a list of UUID's for the suites that were reported.
At least a top level suite is mandatory.

StartSuite startSuite = new StartSuite(
testRunUUID,
parentSuiteUUID, // if applicable
description,
attributes, // Set<Attribute>
suiteNames // List<String>
);

List<UUID> suiteUUIDs = orangebeardClient.startSuite(startSuite);
note

As opposed to test runs, tests or test steps, suites are structure elements. Much like folders in a file system. They are used to group logical sets of tests together and thus have no start- or end time, nor a status. This information is derived from the underlying elements (tests).
Because of this, there is no need to explicitly finish a suite and the API provides no method to do so.

Starting a test

Start a test (inside a test suite). Returns the UUID (Guid) of the started test.

StartTest startTest = new StartTest(
testRunUUID,
suiteUUID,
testName,
testType, // TestType
description,
attributes, // Set<Attribute>
startTime // i.e. ZonedDateTime.now()
);

UUID testUUID = orangebeardClient.startTest(startTest);
tip

TestType is an enumeration with the following values:

TEST, BEFORE, AFTER

Where before and after are used to report set-up or tear down routines.

Finishing a test

Finish a test and reports its final status.

FinishTest finishTest = new FinishTest(
testRunUUID,
testStatus, // TestStatus
endTime
);

orangebeardClient.finishTest(testUUID, finishTest);
tip

The test's status is an enumeration with the following values:

PASSED, FAILED, SKIPPED, STOPPED, TIMED_OUT

Starting a step

Start a step (inside a test). Returns the UUID (Guid) of the started step.

StartStep startStep = new StartStep(
testRunUUID,
testUUID,
parentStepUUID, // if applicable
stepName,
description,
startTime // i.e. ZonedDateTime.now()
);

UUID stepUUID = orangebeardClient.startStep(startStep);

Finishing a step

Finish a step and reports its final status.

FinishStep finishStep = new FinishStep(
testRunUUID,
testStatus, // TestStatus
endTime
);

orangebeardClient.finishStep(stepUUID, finishStep);
tip

The step's status is an enumeration with the following values:

PASSED, FAILED, SKIPPED, STOPPED, TIMED_OUT

The status enum is identical to the test status enum.

Sending a log entry

Reports a log entry to a step or test and return the UUID of the log entry that was created.

Log logEntry = new Log(
testRunUUID,
testUUID,
stepUUID, // if applicable
message, // String
logLevel, // LogLevel
logTime,
logFormat // LogFormat
);

UUID logUUID = orangebeardClient.log(logEntry);
tip

LogLevel is an enumeration with the following values:

DEBUG, INFO, WARN, ERROR

LogFormat is an enumeration with the following values:

PLAIN_TEXT, MARKDOWN, HTML

Attaching a file to a log

AttachmentFile file = new AttachmentFile(
fileName,
fileContent, // byte[]
contentType // String
);

AttachmentMetaData metaData = new AttachmentMetaData(
testRunUUID,
testUUID,
stepUUID, // if applicable
logUUID,
attachmentTime
);

Attachment attachment = new Attachment{
file,
metaData
);

UUID attachmentUUID = orangebeardClient.sendAttachment(attachment);