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

How to get existing case IDs list from a Test run

I am trying to get all Test case IDs from a Test run by using the below api

testRail.runs().get(testRunID).execute().getCaseIds

It is supposed to give me the list of all test case IDs but i am getting null.

My scenario:
I wanted to add testcase in existing Test Run which already have test cases.

Before executing the below code test case 41123 is already available and run ID 1431 has 10 test cases.

If i run the below code, it remove existing 10 cases and add 41123 only.
after debugging i found that “testRail.runs().get(testRunID).execute().getCaseIds” always returning null even test cases already exists.

Is anyone currently facing the same issue? or is it a bug?

used below maven dependency:

com.codepine.api testrail-api-java-client 2.0.0

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.codepine.api.testrail.TestRail;
import com.codepine.api.testrail.model.Run;

public class TestRailJava {
static TestRail testRail;
public static void main(String args) {
TestRailReporter();
List caseIds = new ArrayList<>();
caseIds.add(41123);
Run run = testRail.runs().get(1431).execute();
if (Objects.nonNull(run.getCaseIds())) {
caseIds.addAll(run.getCaseIds());
}
run.setCaseIds(caseIds);
testRail.runs().update(run).execute();
}
public static void TestRailReporter() {
login();
}
public static void login() {
testRail = TestRail.builder(“https://.testrail.io”,“username”,“password”).applicationName(“Automation”).build();
}
}