Subscribe Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

Creating a TestRun with specific name and reading IDs

Hi ,
I m using Java API’s & trying to achieve following

  • Create a TestRun with specific name - Ex : Today’s Date.
  • Get IDs with corresponding Title from this newly created TestRun.

Currently I able to create a TestRun , but it always named as Master and not able to get the IDs and names.

    client = new APIClient("https://xxxxxxxxxxxx.testrail.io/");
	client.setUser("xxxxxxxxxxxx");
	client.setPassword("xxxxxxxxxxx");
	    //Object project = client.sendGet("get_projects");
	Object listOfTestcases = client.sendGet("get_cases/1");
        //client.sendGet("get_runs/1");
	client.sendPost("add_run/1", listOfTestcases);

After this step , Testrun created successfully and all Test cases got added. But i m not able define required name of the testrun and also not able to read test case Ids. Please help.

Hi @Ravi1,
I have several tips for you (the links should give more info):

  1. SendGet & SendPost return a JSONObject or JSONArray.
  2. Each endpoint has several parameters, you just use the required one.
  3. At get_cases you provide the project_id = 1 and because you use a single repository type (I guess so because otherwise the suite_id is missing). But probably you don’t use it in your next call.
  4. add_run has several parameters, especially the name you’re looking for. Passing the cases like you did is IMHO not working, but finally not needed. If you just want to add all cases, there is a flag to indicate this, what is default.
  5. The return value of your sendPost is JSONObject containing all information. If you don’t provide a name at add_run, usually the name of the suite is used, what is in your case ‘Master’.
  6. Therefore you can also call update_run if you like.

In generel I would suggest you to go through the docs first.

Regards
Karsten

Thanks @kwirth for reply … true i overlooked few parameters from API docs.
Now able to achieve both my issues.