Skip to content

Commit dc49b6c

Browse files
authored
Create README.md
1 parent 73a980d commit dc49b6c

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# TestRail API Java Client
2+
--------------------------
3+
A Java client library for [TestRail API](http://docs.gurock.com/testrail-api2/start).
4+
5+
## Quick Start
6+
--------------
7+
8+
### Maven Dependency
9+
```xml
10+
<dependency>
11+
<groupId>io.github.chapeco.api.testrail</groupId>
12+
<artifactId>testrail-api-java-client</artifactId>
13+
<version>2.0.2</version>
14+
</dependency>
15+
```
16+
17+
### Example Usage
18+
```java
19+
// create a TestRail instance
20+
TestRail testRail = TestRail.builder("https://some.testrail.net/", "username", "password").applicationName("playground").build();
21+
22+
// create a new project
23+
Project project = testRail.projects().add(new Project().setName("Playground Project")).execute();
24+
25+
// add a new test suite
26+
Suite suite = testRail.suites().add(project.getId(), new Suite().setName("Functional Tests")).execute();
27+
28+
// add a new section
29+
Section section = testRail.sections().add(project.getId(), new Section().setSuiteId(suite.getId()).setName("Boundary Cases")).execute();
30+
31+
// add a test case
32+
List<CaseField> customCaseFields = testRail.caseFields().list().execute();
33+
Case testCase = testRail.cases().add(section.getId(), new Case().setTitle("Be able to play in playground"), customCaseFields).execute();
34+
35+
// add a new test run
36+
Run run = testRail.runs().add(project.getId(), new Run().setSuiteId(suite.getId()).setName("Weekly Regression")).execute();
37+
38+
// add test result
39+
List<ResultField> customResultFields = testRail.resultFields().list().execute();
40+
testRail.results().addForCase(run.getId(), testCase.getId(), new Result().setStatusId(1), customResultFields).execute();
41+
42+
// close the run
43+
testRail.runs().close(run.getId()).execute();
44+
45+
// complete the project - supports partial updates
46+
testRail.projects().update(project.setCompleted(true)).execute();
47+
```
48+
49+
## Supported TestRail Version
50+
-----------------------------
51+
![TestRail v5.4](https://img.shields.io/badge/TestRail-v5.4-blue.svg)
52+
[![TestRail v5.4](https://img.shields.io/badge/TestRail%20API-v2-orange.svg)](http://docs.gurock.com/testrail-api2/start)
53+
54+
[Old API (aka Mini API)](http://docs.gurock.com/testrail-api/start) 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.
55+
56+
## Notables
57+
------------
58+
59+
### Thin Client Library
60+
Except the initial configration (refer to [example](#example-usage)), this client library does not maintain any state from your TestRail service. You can maintain/cache state on your end if you like.
61+
62+
### Custom Case And Result Fields
63+
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:
64+
```java
65+
// fetch list of custom case field configured in TestRail
66+
List<CaseField> customCaseFields = testRail.caseFields().list().execute();
67+
68+
// get test case
69+
Case testCase = testRail.cases().get(1, customCaseFields).execute();
70+
71+
// assuming separated_steps is a custom TestRail Steps type case field
72+
List<Field.Step> customSteps = testCase.getCustomField("separated_steps");
73+
74+
// work with typed customSteps
75+
......
76+
```
77+
Find the map of supported TestRail field types to Java types in the javadoc of ```Field.Type``` enum.
78+
As mentioned [above](#thin-client-library), since this is a thin library, it does not store the list of fields. You can cache them on your end if you like.
79+
80+
## License
81+
----------
82+
This project is licensed under [MIT license](http://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)