Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

100 Commits

Repository files navigation

TestRail API Java Client


A Java client library for TestRail API.

Maven Central

Quick Start


Maven Dependency

<dependency>
<groupId>com.codepine.api</groupId>
<artifactId>testrail-api-java-client</artifactId>
<version>${stable.version.shown.above}</version>
</dependency>

Example Usage

// create a TestRail instanceTestRailtestRail = TestRail.builder("https://some.testrail.net/", "username", "password").applicationName("playground").build();
// create a new projectProjectproject = testRail.projects().add(newProject().setName("Playground Project")).execute();
// add a new test suiteSuitesuite = testRail.suites().add(project.getId(), newSuite().setName("Functional Tests")).execute();
// add a new sectionSectionsection = testRail.sections().add(project.getId(), newSection().setSuiteId(suite.getId()).setName("Boundary Cases")).execute();
// add a test caseList<CaseField> customCaseFields = testRail.caseFields().list().execute();
CasetestCase = testRail.cases().add(section.getId(), newCase().setTitle("Be able to play in playground"), customCaseFields).execute();
// add a new test runRunrun = testRail.runs().add(project.getId(), newRun().setSuiteId(suite.getId()).setName("Weekly Regression")).execute();
// add test resultList<ResultField> customResultFields = testRail.resultFields().list().execute();
testRail.results().addForCase(run.getId(), testCase.getId(), newResult().setStatusId(1), customResultFields).execute();
// close the runtestRail.runs().close(run.getId()).execute();
// complete the project - supports partial updatestestRail.projects().update(project.setCompleted(true)).execute();

Supported TestRail Version


TestRail v4.1TestRail v4.1

Old API (aka Mini API) is not supported. Please note that you may not be able to use some API features supported by this library depending on the TestRail version you use. Similarly, since this is not an official library, API updates in future versions of TestRail may not be supported immediately with the release of new version or may need an incompatible major version change.

Notables


Thin Client Library

Except the initial configration (refer to example), this client library does not maintain any state from your TestRail service. You can maintain/cache state on your end if you like.

Custom Case And Result Fields

TestRail supports adding custom case and result fields. The request interfaces in TestRail.Cases and TestRail.Results requires a list of these fields in order to allow this library to map them to the correct Java types. Here's an example where we want to to know the separated test steps of a particular test case:

// fetch list of custom case field configured in TestRailList<CaseField> customCaseFields = testRail.caseFields().list().execute();
// get test caseCasetestCase = testRail.cases().get(1, customCaseFields).execute();
// assuming separated_steps is a custom TestRail Steps type case fieldList<Field.Step> customSteps = testCase.getCustomField("separated_steps");
// work with typed customSteps
......

Find the map of supported TestRail field types to Java types in the javadoc of Field.Type enum. As mentioned above, since this is a thin library, it does not store the list of fields. You can cache them on your end if you like.

License


This project is licensed under MIT license.

About

Java client for TestRail API

Resources

Stars

66 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages