1

I am new to TestRail tool and wanted to integrate all my Selenium automation test cases with TestRail. I have 100+ test cases in excel sheet and running using Selenium Webdriver + Java + TestNg.

If I run any of test cases from Selenium project that result should get reflected in TestRail report. Looking around on the internet I found this URL: http://docs.gurock.com/testrail-api2/bindings-java.

But it doesn't tell how to use in my Selenium project. Basically I wanted to know how to use this and where to keep this code. And also if I get detailed example(from TestRail side as well as Selenium Java code) with code would be more helpful to understand.

Nick is tired
  • 6,860
  • 20
  • 39
  • 51
Ramana
  • 11
  • 5
  • Possible duplicate of https://stackoverflow.com/questions/31344490/integrate-selenium-test-results-with-testrail-4-0 – Atul KS Oct 21 '20 at 13:57

1 Answers1

0

You can follow API docs from Testrail:

http://docs.gurock.com/testrail-api2/start

and have to create Your own RESTful service that will lean against Testrail API's.

I've created connection to Testrail with their docs, with additon of JSON (class) models for each of this actions.

For eg. fetching testcases

request:

GET index.php?/api/v2/get_test/:test_id
response:

response:

{
    "assignedto_id": 1,
    "case_id": 1,
    "custom_expected": "..",
    "custom_preconds": "..",
    "custom_steps_separated": [
        {
            "content": "Step 1",
            "expected": "Expected Result 1"
        },
        {
            "content": "Step 2",
            "expected": "Expected Result 2"
        }
    ],
    "estimate": "1m 5s",
    "estimate_forecast": null,
    "id": 100,
    "priority_id": 2,
    "run_id": 1,
    "status_id": 5,
    "title": "Verify line spacing on multi-page document",
    "type_id": 4
}

json model:

public class Test {
    private static final String CUSTOM_FIELD_KEY_PREFIX = "custom_";
    private int id;
    private int caseId;
    private Integer assignedtoId;
    private String title;
    private int statusId;
    private int typeId;
    private int priorityId;
    private Integer milestoneId;
    private Integer runId;
    private String refs;
    private String estimate;
    private String estimateForecast;
    private Map<String, Object> customFields;

    public Map<String, Object> getCustomFields() {
        return customFields;
    }

But probably the easiest way is to directly send request and parse response and create a small service around it.

Kovacic
  • 1,473
  • 6
  • 21