Skip to content

testingbot/testingbot-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven

TestingBotREST Java

A Java client for TestingBot.com's REST API.

Using this client you can interact with the TestingBot API; update Test info, including pass/fail status and other metadata.

https://testingbot.com/support/api

Getting Started

Sign up for an account on TestingBot.com - in the member area you will find the key and secret required to authenticate with the TestingBot API.

TestingbotREST restApi = new TestingbotREST("key", "secret");

All API methods can throw these exceptions:

TestingbotApiException(String json)
TestingbotUnauthorizedException

getBrowsers

Retrieves collection of available browsers https://testingbot.com/support/api

ArrayList<TestingbotBrowser> devices = restApi.getBrowsers();

getDevices

Retrieves collection of available devices https://testingbot.com/support/api#devices

ArrayList<TestingbotDevice> devices = restApi.getDevices();

getAvailableDevices

Retrieves collection of available devices https://testingbot.com/support/api#available-devices

ArrayList<TestingbotDevice> devices = restApi.getAvailableDevices();

getDevice

Retrieves information for a specific device https://testingbot.com/support/api#devicedetails

TestingbotDevice device = restApi.getDevice(int deviceId);

updateTest

Update meta-data for a test https://testingbot.com/support/api#updatetest

  • String status_message
  • boolean success
  • String build
  • String name
boolean success = restApi.updateTest(TestingbotTest test);
boolean success = restApi.updateTest(String sessionId, Map<String, Object> details);

stopTest

Stops a running test https://testingbot.com/support/api#stoptest

boolean success = restApi.stopTest(String sessionId);

deleteTest

Deletes a test from TestingBot https://testingbot.com/support/api#deletetest

boolean success = restApi.deleteTest(String sessionId);

getTest

Retrieves information regarding a test https://testingbot.com/support/api#singletest

TestingbotTest test = restApi.getTest(String sessionId);

getTests

Retrieves a collection of tests https://testingbot.com/support/api#tests

TestingbotTestCollection test = restApi.getTests(int offset, int count);

getBuilds

Retrieves a collection of builds https://testingbot.com/support/api#builds

TestingbotBuildCollection builds = restApi.getBuilds(int offset, int count);

getTestsForBuild

Retrieves a collection of tests for a specific build https://testingbot.com/support/api#singlebuild

TestingbotTestBuildCollection tests = restApi.getTestsForBuild(String buildIdentifier);

getUserConfig

Retrieves information about the current user https://testingbot.com/support/api#user

TestingbotUser user = restApi.getUserInfo();

updateUserConfig

Updates information about the current user https://testingbot.com/support/api#useredit

TestingbotUser user = restApi.updateUserInfo(TestingBotUser);

getTunnels

Retrieves tunnels for the current user https://testingbot.com/support/api#apitunnellist

ArrayList<TestingbotTunnel> tunnels = restApi.getTunnels();

deleteTunnel

Deletes/stops a specific tunnel for the current user https://testingbot.com/support/api#apitunneldelete

boolean success = restApi.deleteTunnel(String tunnelID);

uploadToStorage - Local File

Uploads a local file to TestingBot Storage https://testingbot.com/support/api#upload

TestingbotStorageUploadResponse uploadResponse = restApi.uploadToStorage(File file);

uploadToStorage - Remote File

Uploads a remote file to TestingBot Storage https://testingbot.com/support/api#upload

TestingbotStorageUploadResponse uploadResponse = restApi.uploadToStorage(String fileUrl);

getStorageFile

Retrieves meta-data from a previously stored file https://testingbot.com/support/api#uploadfile

TestingBotStorageFile storedFile = restApi.getStorageFile(String appUrl);

getStorageFiles

Retrieves meta-data from previously stored files https://testingbot.com/support/api#filelist

TestingBotStorageFileCollection fileList = restApi.getStorageFiles(int offset, int count);

deleteStorageFile

Deletes a file previously stored in TestingBot Storage https://testingbot.com/support/api#filedelete

boolean success = restApi.deleteStorageFile(String appUrl);

getAuthenticationHash

Calculates the authenticationHash necessary to share tests https://testingbot.com/support/other/sharing

String hash = restApi.getAuthenticationHash(String identifier);

Closing the client

TestingbotREST holds a pooled HTTP client and implements Closeable. Call close() when you are done (or use try-with-resources) to release connections.

try (TestingbotREST restApi = new TestingbotREST("key", "secret")) {
    restApi.getUserInfo();
}

Tests

getTests with filters

Retrieves a collection of tests with optional server-side filters (since, browser_id, group, build, skip_fields).

Map<String, String> filters = new HashMap<>();
filters.put("group", "smoke");
TestingbotTestCollection tests = restApi.getTests(int offset, int count, filters);

createTest

Creates a new test.

boolean success = restApi.createTest(Map<String, Object> testFields);

Devices

getDevices with filters

Retrieves devices filtered by platform (Android, iOS, REAL_ANDROID, REAL_IOS) and web capability.

List<TestingbotDevice> devices = restApi.getDevices(String platform, Boolean web);

getAvailableDevices

Retrieves the currently available real devices.

List<TestingbotDevice> devices = restApi.getAvailableDevices();

Tunnels

getTunnel

Gets the currently active tunnel, or a specific tunnel by id.

TestingbotTunnel tunnel = restApi.getTunnel();
TestingbotTunnel tunnel = restApi.getTunnel(int tunnelId);

createTunnel

Boots a new tunnel.

TestingbotTunnel tunnel = restApi.createTunnel();

deleteTunnel / isTunnelAlive

Stops the active tunnel, or checks whether the tunnel is alive.

boolean success = restApi.deleteTunnel();
boolean alive = restApi.isTunnelAlive();

Account & configuration

getJob

Gets the status of a job (e.g. a Codeless test run).

TestingbotJob job = restApi.getJob(String jobId);

getUserKeys / getIpRanges

Retrieves your API keys, or the TestingBot IP ranges (raw JSON).

com.google.gson.JsonElement keys = restApi.getUserKeys();
com.google.gson.JsonElement ranges = restApi.getIpRanges();

Team management

TestingbotTeam team = restApi.getTeam();
TestingbotTeamMemberCollection members = restApi.getTeamMembers();
TestingbotTeamMember member = restApi.createTeamMember(Map<String, Object> params);
TestingbotTeamMember member = restApi.getTeamMember(int userId);
TestingbotTeamMember member = restApi.updateTeamMember(int userId, Map<String, Object> params);
com.google.gson.JsonElement clientKey = restApi.getTeamMemberClientKey(int userId);
TestingbotTeamCredentialReset reset = restApi.resetTeamMemberKeys(int userId);

Screenshots

TestingbotScreenshotCollection screenshots = restApi.getScreenshots();
TestingbotScreenshot batch = restApi.createScreenshots(Map<String, Object> params); // url, resolution, browsers (List)
TestingbotScreenshot batch = restApi.getScreenshot(int screenshotId);

Manual sessions

boolean success = restApi.updateManualSession(int sessionId, Map<String, Object> fields);
boolean success = restApi.pingManualSession(List<Integer> sessionIds);

Codeless Lab

TestingbotLabTestCollection labTests = restApi.getLabTests();
TestingbotLabCreateAck created = restApi.createLabTest(Map<String, Object> testFields);
TestingbotLabTest labTest = restApi.getLabTest(int labTestId);
boolean success = restApi.updateLabTest(int labTestId, Map<String, Object> testFields);
boolean success = restApi.deleteLabTest(int labTestId);
TestingbotLabTestStepCollection steps = restApi.getLabTestSteps(int labTestId);
boolean success = restApi.setLabTestSteps(int labTestId, List<String> steps);
List<TestingbotBrowser> browsers = restApi.getLabTestBrowsers(int labTestId);
boolean success = restApi.setLabTestBrowsers(int labTestId, String browserIds);
TestingbotLabRunAck run = restApi.triggerLabTest(int labTestId);
boolean success = restApi.stopLabTest(int labTestId);
boolean success = restApi.addLabTestAlert(int labTestId, Map<String, Object> params); // kind, level, content
boolean success = restApi.updateLabTestAlert(int labTestId, Map<String, Object> params);
boolean success = restApi.createLabTestReport(int labTestId, Map<String, Object> params);
boolean success = restApi.updateLabTestReport(int labTestId, Map<String, Object> params);
boolean success = restApi.scheduleLabTest(int labTestId, Map<String, Object> params); // type, day, hour, cronFormat
TestingbotLabRunAck run = restApi.triggerAllLabTests();

Codeless Lab suites

TestingbotLabSuiteCollection suites = restApi.getLabSuites();
TestingbotLabSuiteCreateAck created = restApi.createLabSuite(Map<String, Object> suiteFields);
TestingbotLabSuite suite = restApi.getLabSuite(int suiteId);
boolean success = restApi.deleteLabSuite(int suiteId);
TestingbotLabTestCollection tests = restApi.getLabSuiteTests(int suiteId);
boolean success = restApi.addLabSuiteTests(int suiteId, String testIds);
boolean success = restApi.removeLabSuiteTest(int suiteId, int testId);
List<TestingbotBrowser> browsers = restApi.getLabSuiteBrowsers(int suiteId);
boolean success = restApi.setLabSuiteBrowsers(int suiteId, String browserIds);
TestingbotLabRunAck run = restApi.triggerLabSuite(int suiteId);

Test

TestingbotRestOfflineTest (auth-hash + Gson mapping) and TestingbotRestMockTest (every endpoint, against a local HttpServer) run with no credentials:

mvn -Dtest='TestingbotRestOfflineTest,TestingbotRestMockTest' test

TestingBotRestTest runs against the live API and needs your key and secret:

mvn -DTB_KEY=... -DTB_SECRET=... test

Maven

<dependencies>
  <dependency>
    <groupId>com.testingbot</groupId>
    <artifactId>testingbotrest</artifactId>
    <version>1.0.8</version>
    <scope>test</scope>
  </dependency>
</dependencies

Packages

 
 
 

Contributors

Languages